Oct-26-2016, 01:21 AM
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
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
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