Telnet Problem

DeepBleu DeepBleu at DeepBleu.org
Tue Jan 15 11:39:44 EST 2002


Thank you Eddie
Right after posting my message I sent a cancellation but you got my original
post first.
This is exactly what was happening.  Connection closing before even the
process had a chance to start.  So of course it was running fine in
interactive mode :O
I included a tn.read_until(ExpectedString) before closing and it works fine
now.
DeepBleu

"Eddie Corns" <eddie at holyrood.ed.ac.uk> wrote in message
news:a21igg$gj0$1 at scotsman.ed.ac.uk...
> "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