Created
April 21, 2014 03:45
-
-
Save curzona/11131661 to your computer and use it in GitHub Desktop.
Multiple command shell session with paramiko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
client = paramiko.SSHClient() | |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
client.connect('HOST', port=22, username='USERNAME', password='PASSWORD') | |
channel = client.get_transport().open_session() | |
channel.invoke_shell() | |
while channel.recv_ready(): | |
channel.recv(1024) | |
channel.sendall("pwd\n") | |
print channel.recv(1024) | |
channel.sendall("cd..\n") | |
channel.sendall("pwd\n") | |
print channel.recv(1024) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works well thanks a lot!