Nathan, Depending upon how much control you have over the calling machine you can eliminate the pesky password prompt from ssh altogether by creating a private/public key pair for the client machine and copy the public key to the host machine. This way when you ssh to the host you will be authenticated based on the key pair. Check out ssh-copy-id.
Mark On Fri, 2009-10-16 at 13:45 -0600, Nathan Farrar wrote: > 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 > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor