I'm trying to automate the collection of data to remote devices over
ssh via pexpect.  I had originally attempted (with limited success) to
use paramiko, however due to cisco's ssh implimentation I cannot send
mulitple commands over the same connection, which is absolutely
essential.  Therefore, I'm now attempting to use pexpect, but am
having trouble getting started.  I have a simple script, such as:

session = pexpect.spawn('ssh u...@host')
session.expect([pexpect.TIMETOUT, 'password:'])
session.send('password')
print session.read() # shouldn't this display the logon banner & command prompt?
session.close()

This code results in no output & a hanging window. What am I doing incorrect?

Additionally, I will need to add conditional pexpect statements, such
that when I execute a command I want to gather the output, however if
'--More--' is encountered (and it this can happen multiple times), I
want to send a newline character to the session and continue gathering
the output.

Thanks for the help!
Nathan

-- 
"The presence of those seeking the truth is infinitely to be preferred
to the presence of those who think they've found it."

–Terry Pratchett
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to