problems with telnetlib

Jeff jam at quark.emich.edu
Tue Aug 1 17:49:18 EDT 2000


On Wed, Jul 26, 2000 at 02:14:17PM -0400, jtoy wrote:
> I have tried several sample scripts including the oses at python.org,
> but I can't get any of the scripts to work properly.  I have Python
> 1.5.2 on Linux 2.2.15.  All I want to do is write a script that telnets
> into a machine and executes '/etc/email'.  I can safely get up to the
> password prompt with:
> 
> from telnetlib import Telnet
> tn = Telnet('192.168.0.254')
> tn.read_until('login: ')
> tn.write('someuser\n')
> tn.read_until('password: ')
> tn.write('password\n')
> tn.read_until('$ ')
> 
> then I get error in line 224 read_very_lazy and in 300 read_very_lazy
> My exact login prompt after a normail telnetsession is:
> [user at localnet user]$
> So reading until '$' should be write.  Also, after I type
> tn.read_until('password: '), thr python prompt freezes for 30 seconds
> but continues normally after, why is this?
> 

on my redhat machine, the 'password' prompt has a capital 'P', i.e.:

tn.read_until("assword:")

ought to solve your problem nicely.. at least in terms of the pausing you
mentioned. 

as for the other problems, can't be sure what to suggest other than use the
'debuglevel' method right after you connect, i.e.:
tn.debuglevel(255)

you might also want to check the docs for the telnetlib module for other
troubleshooting clues:
http://www.python.org/doc/current/

hope that helps..

regards,
J
-- 
|| visit gfd <http://quark.emich.edu/>
|| psa member -- <http://www.python.org/psa/> 




More information about the Python-list mailing list