summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2010-10-17 11:01:22 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2010-10-17 11:01:22 +0000
commit5fbd9e22c95cb373c15f77bf421b29f6f2e24235 (patch)
treefe1201a7f5517be743b4c1cd79b112f10a99b9b5
parent11d5c5672993ff149f26a776ff6b2156b022a23a (diff)
downloadpexpect-5fbd9e22c95cb373c15f77bf421b29f6f2e24235.tar.gz
Added Lars Nordin patch.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@523 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r--pexpect/pxssh.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py
index 5856b2c..9dd67b3 100644
--- a/pexpect/pxssh.py
+++ b/pexpect/pxssh.py
@@ -7,6 +7,7 @@ $Id$
from pexpect import *
import pexpect
import time
+import os
__all__ = ['ExceptionPxssh', 'pxssh']
@@ -131,6 +132,8 @@ class pxssh (spawn):
# All of these timing pace values are magic.
# I came up with these based on what seemed reliable for
# connecting to a heavily loaded machine I have.
+ self.sendline()
+ time.sleep(0.1)
# If latency is worse than these values then this will fail.
try:
@@ -159,7 +162,7 @@ class pxssh (spawn):
### TODO: This is getting messy and I'm pretty sure this isn't perfect.
### TODO: I need to draw a flow chart for this.
- def login (self,server,username,password='',terminal_type='ansi',original_prompt=r"[#$]",login_timeout=10,port=None,auto_prompt_reset=True):
+ def login (self,server,username,password='',terminal_type='ansi',original_prompt=r"[#$]",login_timeout=10,port=None,auto_prompt_reset=True,ssh_key=None):
"""This logs the user into the given server. It uses the
'original_prompt' to try to find the prompt right after login. When it
@@ -189,6 +192,12 @@ class pxssh (spawn):
ssh_options = ssh_options + ' ' + self.SSH_OPTS
if port is not None:
ssh_options = ssh_options + ' -p %s'%(str(port))
+ if ssh_key is not None:
+ try:
+ os.path.isfile(ssh_key)
+ except:
+ raise ExceptionPxssh ('private ssh key does not exist')
+ ssh_options = ssh_options + ' -i %s' % (ssh_key)
cmd = "ssh %s -l %s %s" % (ssh_options, username, server)
# This does not distinguish between a remote server 'password' prompt