[Q] telnetlib
yoonseo at my-deja.com
yoonseo at my-deja.com
Fri Jan 19 15:01:03 EST 2001
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/
More information about the Python-list
mailing list