Telnet Program

Rob Wolfe rw at smsnet.pl
Tue Jan 29 14:27:08 EST 2008


"paul.zorn at gmail.com" <paul.zorn at gmail.com> writes:

> I am having some issues writing a telnet program, using telnetlib. I
> am not sure if it is the telnet on the connections end or it is my
> program.
>
> A little background, when I log in straight from the Linux Command
> prompt. The only thing I get is a blinking cursor. Then I type in my
> command 'FOO' enter then screen on the very next line returns 'OK',
> Then automatically puts the blinking cursor on the next line. Then
> when I want to quit the telnet session I hit CTRL+Z that takes me to
> telnet> then i type quit.
>
> My Program currently looks like it connects. Because the last string
> that I get back that is not blank says: "Logged in successfully".
>
> So my problem is that when I issue the command through tn.write("FOO
> \n"). Then do a tn.read_until('OK\n', 10). It gets returned nothing. I
> have also added tn.read_until('OK\n', 10).splitlines(). That is also
> returned blank.
>
> I have tried various different newlines \n \r \r\n. All the
> documentation for telnet program that I am logging into says, use
> Carriage Return after each command. Nothing seems to get back the
> data. I am not sure if the Python telnet is looking for more of true
> command line like telnet>.

Have you tried: tn.set_debuglevel(1) ?

HTH,
Rob



More information about the Python-list mailing list