Reputation: 1304
The following command works fine on the shell
ssh hostname 'pgrep -fn "java -cp /strbase/apps/App"'
However not in the python subprocess, I have my array as follows
cmd_array = ['ssh', 'hostname', "'pgrep", '-fn', '"java', '-cp', '/strbase/apps/App"\'']
However I get no output.
I am trying below:
process = subprocess.Popen(
cmd_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
However
stdout
evalutes to an empty string, it should give me back a number. Why is this? It works fine in the shell?
Upvotes: 0
Views: 48
Reputation: 1280
Your cmd_array
is wrong, you send only two argument, hostname and your command string, it's should be :
cmd_array = ["ssh", "hostname", 'pgrep -fn "java -cp /strbase/apps/App"']
Upvotes: 1