Telnet Problem

Eddie Corns eddie at holyrood.ed.ac.uk
Tue Jan 15 10:40:00 EST 2002


"DeepBleu" <DeepBleu at DeepBleu.org> writes:

>I am running into the following frustration problem:
>I am telneting a server to run a command on it.  When I run the script in
>interactive mode (line by line in PythonWin 2.1.211), it works.  When I run
>the script, it does not work.
>This is the very simple script:
>######################### Start
>from telnetlib import Telnet
>tn=Telnet("dvlp")
>tn.read_until("login: ")
>tn.write("UserID\n")
>tn.read_until("Password: ")
>tn.write("UserPWD\n")
>tn.read_until("data>")
>tn.write("cd ..\n")
>tn.read_until("server>")
>tn.write("cd bin\n")
>tn.read_until("bin>")
>tn.write('newjob "par1" "PathToFile" "PythonWin Test"' + "\n")
>tn.close()
>################################################## End
>As I said, when I run it line by line,  the process 'newjob "par1"
>"PAthToFile" "PythonWin Test"'  takes place fine.  When run in the regular
>way as a script,  the same process does not take place.
>Can anyone help with any hints.
>Thanks,
>DeepBleu

Try doing a read_until() after the final write and before the close().  What's
probably happening is that the connection close is causing the far end to
terminate the session.

Eddie




More information about the Python-list mailing list