Is there any way to SSH from Python ?!

Godson Gera godson.g at gmail.com
Mon Dec 13 16:20:40 EST 2010


On Mon, Dec 13, 2010 at 10:33 AM, Darshak Bavishi <bavishi.darshak at gmail.com
> wrote:

> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

you can try read_very_eager() which won't block. Twisted has complete
support for SSH check it out http://twistedmatrix.com

-- 
Thanks & Regards,
Godson Gera
Asterisk Consultant India <http://godson.in>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101214/5033a34a/attachment-0001.html>


More information about the Python-list mailing list