use pexpect to set the prompt after the login.
class Login(General):
"""Class spawning an ssh expect instance"""
def __init__(self, user, host, pwd, cfg_name=None, log=None):
if cfg_name:
self.testcell = test_config(cfg_name)
self.spawn = pexpect.spawn("ssh %s@%s" % (user, host), [], 100)
if log:
self.spawn.logfile = log
sshreply = self.spawn.expect(["Last login", "assword", "connecting"])
if sshreply == 1:
self.spawn.sendline(pwd)
self.spawn.expect("Last login")
elif sshreply == 2:
time.sleep(0.1)
self.spawn.sendline("yes")
print self.spawn.after
Login(user, host, cfg_name, log)
time.sleep(1)
self.prompt=prompt_chg(self.spawn, "PROMPT:")
self.spawn.sendline("uname -a")
self.spawn.expect(self.prompt)
On Jan 23, 10:28 am, Willi Richert <w.rich...@gmx.netwrote:
Am Dienstag, 23. Januar 2007 02:16 schrieb Nanjundi:
BJörn Lindqvist wrote:
I want to use Python to connect to a SSH account over a HTTP proxy to
automate some operations. I thought paramiko would be able to do that,
but it can not (it seems).
Is there some other Python module that can do what I want?
--
mvh Björn
Did you take a look at twisted library?
twistedmatrix.com
http://twistedmatrix.com/projects/co...o/clients.html
I haven't tried to connect over port 80, but its worth a try.
-NIf you need it for automation you might want to usepexpect:http://pexpect.sourceforge.net/
It listens to the tty-stream and simulates a user typing in commands. It is
very useful, e.g. if you want to start processes on many machines over ssh.
If there are gateways/firewalls between - no problem just use a
second "sendline('ssh user@nextmachine')"
The only problem is the regular expression: If e.g. you use a custom $PS1
variable for your prompt you have to account for that.
Regards,
wr