0

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?

1 Answer 1

1

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"']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.