Can someone tell me how to get the output of the following command using subprocess to a list please?
curl --silent -u username:password http://localhost:55672/api/queues | sed 's/,/\n/g' | grep '"name"\:' | tr -d "name:" | tr -d -d \"
Tried "subprocess.popen", "subprocess.call" and "subprocess.popen" but to no avail. Below is one example i tried.
import json
import subprocess
HO=subprocess.check_output("curl --silent -u username:passwordhttp://localhost:55672/api/queues | sed 's/,/\n/g' | grep '"name"\:' | tr -d "name:" | tr -d -d \"", shell=True)
print HO
The error that is thrown at me when the latter is run
File "./rb.py", line 10
HO=subprocess.check_output("curl --silent -u username:password http://localhost:55672/api/queues | sed 's/,/\n/g' | grep '"name"\:' | tr -d "name:" | tr -d -d \"", shell=True)
^
SyntaxError: invalid syntax
[my_shell]bindo@test1:~/rbmq_test $
Please note that the command is working when it is run on the shell and generates an output in below format
line1
line2
line3
Please can someone help?