By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,403 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,403 IT Pros & Developers. It's quick & easy.

how to read o/p of telenet (python) ?!

P: 10
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()
Dec 10 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.