MobilAdmin Posted September 14, 2009 Posted September 14, 2009 I have a paging server that can send out pages through telnet. I've been trying to figure out just how to do this with autoit, but have had no luck. I just need very simple commands. The process through the command line is this... >telnet server.company.net 444 ### Company SNPP Gateway Ready >page ####### Pager ID Accepted >mess "Message to be sent" ### Message Ok >send ### Message Sent Successfully I have tried the TCP commands with no success. Any help would be greatly appreciated. Thank you.
jvanegmond Posted September 14, 2009 Posted September 14, 2009 This is off the top of my head. May not be correct, but it shows the principle of telnet. TCPStartup() $ip = TCPNameToIP("server.company.net") $socket = TCPConnect($ip, 444) $var = _WaitForInput() ; $var contains ### Company SNPP Gateway Ready TCPSend($socket, "page ######") $var = _WaitForInput() ; Pager ID Accepted TCPSend($socket, "mess ""Message to be sent""") $var = _WaitForInput() ; ### Message Ok TCPSend($socket, "send") $var = _WaitForInput() ; ### Message Sent Succesfully Func _WaitForInput() While 1 $data = TCPRecv($socket, 512) If $data <> "" Then Return $data Wend EndFunc github.com/jvanegmond
MobilAdmin Posted September 14, 2009 Author Posted September 14, 2009 I have tried the suggested script and the execution hangs. I'm not sure where to go from here. Thanks for the help.
jvanegmond Posted September 14, 2009 Posted September 14, 2009 (edited) This is off the top of my head. May not be correct.Do the first 3 line work for you? Do some debugging. Edited September 14, 2009 by Manadar github.com/jvanegmond
MobilAdmin Posted September 14, 2009 Author Posted September 14, 2009 The connection is not being made at all. I'm new to this program and I'm not sure how to debug a script like this. I do know that the connection is not there. I just copied and pasted, then adjusted the details. I'm at a loss.
jvanegmond Posted September 14, 2009 Posted September 14, 2009 If this works: telnet server.company.net 444 Then this works too: TCPStartup() $ip = TCPNameToIP("server.company.net") $socket = TCPConnect($ip, 444) github.com/jvanegmond
MobilAdmin Posted September 14, 2009 Author Posted September 14, 2009 I believe that its hanging because its not getting any data back to move onto the next line of the code. I can use telnet to do this and it works fine. What I had originally wrote is exactly what I see on the screen. Where to go from here?
jvanegmond Posted September 14, 2009 Posted September 14, 2009 Try this for debugging: TCPStartup() $ip = TCPNameToIP("server.company.net") $socket = TCPConnect($ip, 444) $var = _WaitForInput() ; $var contains ### Company SNPP Gateway Ready TCPSend($socket, "page ######") $var = _WaitForInput() ; Pager ID Accepted TCPSend($socket, "mess ""Message to be sent""") $var = _WaitForInput() ; ### Message Ok TCPSend($socket, "send") $var = _WaitForInput() ; ### Message Sent Succesfully Func _WaitForInput() Sleep(1000) EndFunc github.com/jvanegmond
MobilAdmin Posted September 14, 2009 Author Posted September 14, 2009 The scripted runs through to the end, but the message doesn't go out.
jvanegmond Posted September 14, 2009 Posted September 14, 2009 It's something that you are doing wrong. I have tried all sorts of setups, and can safely confirm that this works in establishing a telnet connection. I've even made a small script to let you learn a little more about the TCP functions: Local $packet, $data, $ip, $socket $packet = "GET / HTTP/1.1" & @CRLF & _ "Host: www.google.com" & @CRLF & _ @CRLF TCPStartup() $ip = TCPNameToIP("www.google.com") $socket = TCPConnect($ip, 80) TCPSend($socket, $packet) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd For more help, post more information: What you are doing, what is the telnet server, what packets are going out, what are the return variables of the functions etc. I'm out for a while. github.com/jvanegmond
One Posted June 7, 2016 Posted June 7, 2016 Was same problem... Just add @CRLF to all tcpsend messages. expandcollapse popupTCPStartup() $var = _WaitForInput() $ip = TCPNameToIP("***************") $var = _WaitForInput() ; $socket = TCPConnect($ip, 4444) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd TCPSend($socket, "PAGE *************"&@CRLF) ConsoleWrite("PAGE *************"&@CRLF) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd TCPSend($socket, "MESS 1234567"&@CRLF) ConsoleWrite("MESS 1234567"&@CRLF) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd TCPSend($socket, "SEND"&@CRLF) ConsoleWrite("SEND"&@CRLF) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd TCPSend($socket, "QUIT"&@CRLF) ConsoleWrite("QUIT"&@CRLF) While 1 $data = TCPRecv($socket, 512) If ($data <> "") Then ConsoleWrite($data) ExitLoop EndIf Sleep(50) WEnd TCPShutdown() ; Close the TCP service. Func _WaitForInput() Sleep(3000) EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now