Jump to content

Recommended Posts

Posted

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.

Posted

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
Posted

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.

Posted

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?

Posted

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
Posted

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.

  • 6 years later...
Posted

Was same problem...

Just add @CRLF to all tcpsend messages.

 

TCPStartup()
$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

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...