python libraries for ssh handling

Since you’re not doing anything special at the protocol level, you presumably don’t need the protocol to be entirely implemented in python, and you could simply run ssh/scp commands using the subprocess module. import subprocess subprocess.check_call([‘ssh’, ‘server’, ‘command’]) subprocess.check_call([‘scp’, ‘server:file’, ‘file’])

Python how to read output from pexpect child?

In pexpect the before and after attributes are populated after an expect method. The most common thing used in this situation is waiting for the prompt (so you’ll know that the previous command finished execution). So, in your case, the code might look something like this: child = pexpect.spawn (‘/bin/bash’) child.expect(“Your bash prompt here”) child.sendline(‘ls’) … Read more