how to read o/p of telenet (python) ?!
Darshak Bavishi
bavishi.darshak at gmail.com
Sat Dec 11 06:20:35 EST 2010
hi experts ,
i have code to telnet remote machine (unix)
i am using port 5400 to telnet but o/p is not in visible format when i run
random commands or run
when i give as read_some() it displays some lines but in case of read_all()
it gets hang !!
In actual i want to get some string from o/p and process pls help
[code]
import getpass
import sys
import telnetlib
import time
HOST = "hostname"
#user = raw_input("Enter your remote account: ")
#password = getpass.getpass()
user = "hostname"
password = "ABC"
tn = telnetlib.Telnet(HOST , 5400)
print "1"
print "2"
tn.write(user + "\n")
print "3"
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
print "4"
tn.write("set alarm = off" + "\n")
tn.write("set event = off" + "\n")
print "5"
tn.write("Cd /Office-Parameters/" + "\n")
print "6"
tn.write("\n")
tn.write("\n")
tn.write("vlrsubquery msisdn=*******" + "\n")
tn.write("\n")
print tn.read_all()
tn.write("exit" + "\n")
tn.close()
--
BR
Darshak Bavishi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101211/b0ae8222/attachment-0001.html>
More information about the Python-list
mailing list