telnetlib

Dickerson, Dee Dickerson4 at dow.com
Fri Jan 10 10:11:55 EST 2003


Below is telnet code that I am trying to get going.  I am going from a Windows2000 machine to a Redhat Linux machine; the ls command will not run as I can tell; it does not return any output.
 
I need to be able to execute other commands such as ps with options such as
 
ps -eda -format pid,command |grep legion-server,,,,, etc|
 
I would appreciate any help that anyone could offer.
 
 
import telnetlib
import sys
from hostlistdee import hostlistdee
 
user='legion'
pw='*******'
 
for host in hostlistdee:
   try:
      tn=telnetlib.Telnet(host)
      tn.read_until("login: ")
      tn.write(user+'\n') 
      tn.read_until('Password: ')
      tn.write(pw+'\n')
      tn.write('ls\n')
      tn.write('exit\n')
      tn.read_all()
      tn.close()
      print 'started ',host
   except:
      print 'failed ',host
   # end try
# end def
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030110/bd03de2c/attachment.html>


More information about the Python-list mailing list