I am trying to call remote (ssh) commands using the subprocess.call function like this.
import shlex
from subprocess import call
cmd1='ssh [email protected] mkdir temp'
cmd2='scp test.txt [email protected]:temp'
call(shlex.split(cmd1))
call(shlex.split(cmd2))
When I call the above, the mkdir does not seem to execute - although the documentation for subprocess.call says it waits for execution before returning. The latency of the individual ssh calls is about 0.5 seconds. It seems to work fine on the gigabit LAN where the latency is almost zero.
However it seems to work fine when the calls are made like this:
call(shlex.split(cmd1)) & call(shlex.split(cmd2))
What is the problem with the first approach?
Thank you, Miliana