3rd command never executed in remote machine using paramiko
mandalmanas786 at gmail.com
mandalmanas786 at gmail.com
Tue Oct 25 14:06:14 EDT 2016
I have written below code to run 3 command in remote server interactively
But when i checked 3rd command never executed and code stuck here is my code
def execute():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ipaddress',username='user', password='pw')
chan=ssh.invoke_shell() # start the shell before sending commands
chan.send('cd /path to folder/test')
chan.send('\n')
time.sleep(3)
chan.send("ls -l")
chan.send('\n')
buff=''
while not buff.endswith(">"):
resp = chan.recv(9999)
# code stuck here after 'path to folder/test >' comes in shell prompt
buff+=resp
print resp
print "test"
chan.send("ls -lh")
chan.send('\n')
time.sleep(5)
buff=''
while not buff.endswith(">"):
resp = chan.recv(9999)
buff+=resp
print resp
if __name__ == "__main__":
execute()
When i ran i got output of ls -l but ls -lh never executed my code stuck in first while loop. Anyone please help to resolve my issue
When i reduced bytes to read size then it executed 3rd script.
More information about the Python-list
mailing list