diff options
Diffstat (limited to 'pexpect/examples/ssh_session.py')
-rwxr-xr-x | pexpect/examples/ssh_session.py | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/pexpect/examples/ssh_session.py b/pexpect/examples/ssh_session.py index 4d0e228..d550b51 100755 --- a/pexpect/examples/ssh_session.py +++ b/pexpect/examples/ssh_session.py @@ -1,14 +1,35 @@ -# -# Eric S. Raymond -# -# Greatly modified by Nigel W. Moriarty -# April 2003 -# +#!/usr/bin/env python + +""" + Eric S. Raymond + + Greatly modified by Nigel W. Moriarty + April 2003 + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier <noah@noah.org> + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" + from pexpect import * import os, sys import getpass import time - + class ssh_session: "Session with extra state including the password to be used." @@ -26,9 +47,9 @@ class ssh_session: 'Command not found.', EOF, ] - + self.f = open('ssh.out','w') - + def __repr__(self): outl = 'class :'+self.__class__.__name__ @@ -61,7 +82,7 @@ class ssh_session: # Added to allow the background running of remote process if not child.isalive(): seen = child.expect(self.keys) - if seen == 2: + if seen == 2: lines = child.readlines() self.f.write(lines) if self.verbose: |