Jump to content
Sign in to follow this  
meekaah

Wait for string during TCP

Recommended Posts

meekaah

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

Share this post


Link to post
Share on other sites
meekaah

so, nobody has an idea? :)

Share this post


Link to post
Share on other sites
meekaah

i can't beleive nobody knows this...

im sure it's possible but can't find anything, im waiting for a little help, thanks in advance :)

Share this post


Link to post
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
Sign in to follow this  

×