I'm trying to write a simple script which will connect to a computer via telnet, run a couple commands (ehlo/vrfy) and get back the results. the purpose being i need to do this to verify if something exists already.
I can get everything to work if i open a telnet window and manually do it but i want to be able to easily fire off this lookup tool as i need it.
here is my initial tcpconnect test code:
TCPStartup()
$ip = TCPNameToIP("$domain")
ConsoleWrite($ip & @CRLF)
$Socket = TCPConnect($ip, 25)
If $Socket = -1 Then
ConsoleWrite('i die' & @crlf)
Exit
EndIf
;
Sleep(500)
$recv = TCPRecv($Socket, 500)
$err = @error
If $recv <> "" then
ConsoleWrite('Received: ' & $recv & @crlf)
else
ConsoleWrite('got nothing? ' & $recv & ":: " & $err & @CRLF)
EndIf
$send = TCPSend($Socket, "help" & @CR)
$recv = TCPRecv($Socket, 500)
If $recv <> "" then
ConsoleWrite('Received: ' & $recv & "::" & $send & @crlf)
else
ConsoleWrite('got nothing? ' & $recv & " :: " & $send & @CRLF)
EndIf
TCPCloseSocket($Socket)
TCPShutdown ( )
the result of this block is :
###.##.###.###
got nothing? :: 0
got nothing? :: 5
so $socket exists. tcpsend is sending 5 bytes successfully and even though i'm not getting anything back TCPRecv() is not setting @error so technically it should be working too.
I can't seem to figure out why TCPRecv() isnt giving anything back but everything else seems successful.