Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paramiko SSH exec_command (shell script) returns before completion

I launch a shell script from a remote Linux machine using Paramiko. The shell script is launched and execute a command make -j8. However the exec_command returns before the completion of the make.

If I launch the script on the local machine it executes correctly.

Could someone explain me this behaviour?

like image 911
Larry Avatar asked Jul 09 '10 19:07

Larry


1 Answers

You need to wait for application to finish, exec_command isn't a blocking call.

print now(), "before call"
stdin, stdout, sterr = ssh.exec_command("sleep(10)")
print now(), "after call"
channel = stdout.channel
print now(), "before status"
status = channel.recv_exit_status()
print now(), "after status"
like image 199
deft_code Avatar answered Sep 28 '22 07:09

deft_code