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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darshak bavishi
    New Member
    • Dec 2010
    • 10

    #1

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

    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("Ente r your remote account: ")
    #password = getpass.getpass ()


    user = "hostname"
    password = "ABC"


    tn = telnetlib.Telne t(HOST , 5400)
    print "1"

    print "2"
    tn.write(user + "\n")
    print "3"
    if password:
    tn.read_until(" Password: ")
    tn.write(passwo rd + "\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("vlrsu bquery msisdn=*******" + "\n")
    tn.write("\n")

    print tn.read_all()

    tn.write("exit" + "\n")

    tn.close()
Working...