Is there any way to SSH from Python ?!

Darshak Bavishi bavishi.darshak at gmail.com
Mon Dec 13 00:03:07 EST 2010


Hi Experts,

I need to know that is there any way to SSH (From Windows Host) to Unix
machine ?!

If Yes than How ?

Because when i use telenet it not showing the no result !! As earlier it was
suggested that i should try with exit first and than read_all()
but still issue persist and getting hang

import getpass
import sys
import telnetlib
import time
HOST = "*.*.*.*"
#user = raw_input("Enter your remote account: ")
#password = getpass.getpass()
user = "Darshak2"
password = "****"
tn = telnetlib.Telnet(HOST , 5400)
print "1"
tn.read_until("login:" , 5)
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/Mobility-Config-Parameters/Subscriber-Query-by-IMSI-MSISDN-or-IMEI"
+ "\n")
print "6"
tn.write("\n")
tn.write("\n")
tn.write("vlrsubquery msisdn=***" + "\n")
tn.write("\n")
tn.write("exit" + "\n")
print tn.read_all()
tn.close()

-- 
BR
Darshak Bavishi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101213/3ea49135/attachment-0001.html>


More information about the Python-list mailing list