Jump to content

Wait for string during TCP


Recommended Posts

Hi, i have little telnet client in tcp

and i want to wait for a specific string to continue with the script.

but i dont seem to find anything that fits.

he'res my little bit of code:

TCPStartUp()
$socket = TCPConnect( "169.254.0.2" , 23 )
If @error Then
    MsgBox(4112,"Error","Connexion not possible!")
    Exit
EndIf
sleep(400)
$data = "cd /mnt/fat"
$retour = tnSend($socket,$data)
$data = "wget http://file.com/file"
$retour = tnSend($socket,$data)

TCPCloseSocket($socket)

Func tnSend($socket, $texte)
    $retour = ""
    TCPSend($socket,$texte & chr(10))
    If @error Then
        MsgBox(4112,"Error","TCPSend failed with WSA error: " & @error)
        Exit
    EndIf
    sleep(1000)
    $recv="fin"
    while $recv<>""
        $recv = TCPRecv( $socket, 2048 )
        If @error Then
            MsgBox(4112,"Error","TCPRecv failed with WSA error: " & @error)
            Exit
        EndIf
        sleep(100)
        $retour = $retour & $recv
    WEnd
    Return $retour
EndFunc

I want to wait for a "#" after the wget to know when the file is done downloading

$data = "wget http://file.com/file"
$retour = tnSend($socket,$data)

Thanks in advance

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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