I’m trying to execute the following code but it is not working
p = subprocess.Popen("ssh root@IP cd /opt/msys/pe2/bin;./perlscript.pl; -a file.csv",
shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
OR:
p = subprocess.Popen("ssh root@IP /opt/msys/pe2/bin/perlscript.pl; -a file.csv",
shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
The problem with the first is i can seem to chain together commands after ssh. The 2nd is if i call the file directly the -a arg can’t find that file because im not in that directory. I was hoping to use the cwd parameter to Popen, but it fails because I’m not ssh’d into the server.
Try quoting the command being sent to ssh:
Otherwise you’re telling the local shell to do it.