[Q] telnetlib

Doug Stanfield DOUGS at oceanic.com
Sat Jan 20 20:37:17 EST 2001


Just a guess, but you may not be following exactly the sequence of strings
are exchanged when you telnet to this device.  Try to manually log in and
copy the session to a followup.

-Doug-

> -----Original Message-----
> From: yoonseo at my-deja.com [mailto:yoonseo at my-deja.com]
> Sent: Friday, January 19, 2001 10:01 AM
> To: python-list at python.org
> Subject: [Q] telnetlib
> 
> 
> Hi,
> 
> I am trying to run commands on a remote computer using Python.
> I think that using 'telnetlib' is the way to go, but I have trouble.
> The following is the script that I wrote but it stops before
> it reaches prompt, that is after 'TERM = (vt100) '.
> Can somebody tell me what is wrong?
> 
> Thanks in advance
> 
> sy
> 
> 
> --------------------------------------
> import telnetlib
> 
> HOST = 'host_name'
> user = 'user_name'
> pwd  = 'my_password'
> 
> tn = telnetlib.Telnet(HOST)
> 
> print tn.read_until('login: ')
> tn.write(user+'\n')
> 
> print tn.read_until('Password:')
> tn.write(pwd+'\n')
> 
> print tn.read_until('TERM = (vt100) ')
> tn.write('\n')
> 
> print tn.read_until('% ')
> tn.write('ls\n')
> 
> print tn.read_until('% ')
> tn.write('exit\n')
> 
> print tn.read_all()
> --------------------------------------
> 
> 
> Sent via Deja.com
> http://www.deja.com/
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list