summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2002-09-20 13:53:08 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2002-09-20 13:53:08 +0000
commit4223b00fd1072bac46aa1eefca7b64d97c27eae3 (patch)
tree5c6bfcf3b949f2777be9452c5b10742026b47f6c
parent137d6a5910549493febc8be298a2dd82d7d0e025 (diff)
downloadpexpect-4223b00fd1072bac46aa1eefca7b64d97c27eae3.tar.gz
Made passmass.py a little more robust.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@70 656d521f-e311-0410-88e0-e7920216d269
-rwxr-xr-xpexpect/examples/passmass.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pexpect/examples/passmass.py b/pexpect/examples/passmass.py
index bb5fb51..646ca37 100755
--- a/pexpect/examples/passmass.py
+++ b/pexpect/examples/passmass.py
@@ -12,7 +12,6 @@ SHELL_PROMPT = '[#\$] '
def login(host, user, password):
child = pexpect.spawn('ssh %s@%s'%(user, host))
- child.log_open('LOG')
child.expect('password:')
child.sendline(password)
i = child.expect(['Permission denied', SHELL_PROMPT, 'Terminal type'])
@@ -26,16 +25,17 @@ def login(host, user, password):
def change_password(child, user, oldpassword, newpassword):
child.sendline('passwd %s'%user)
- i = child.expect(['Old password', 'New password'])
+ i = child.expect(['Old [Pp]assword', 'New [Pp]assword'])
# Root does not require old password, so it gets to bypass the next step.
if i == 0:
child.sendline(oldpassword)
- child.expect('New password')
+ child.expect('New [Pp]assword')
child.sendline(newpassword)
- i = child.expect(['New password', 'Retype new password'])
+ i = child.expect(['New [Pp]assword', 'Retype', 'Re-enter'])
if i == 0:
print 'Host did not like new password. Here is what it said...'
print child.before
+ child.send (chr(3)) # Ctrl-C
child.sendline('') # This should tell remote passwd command to quit.
return
child.sendline(newpassword)