| Not Working In Subprocess.call
Whenever I use a command in a subprocess with '|' in it doesn't work it has an output of Command '|' is unknown, try 'in link help'. Or when I put this: #!/usr/bin/python fro
Solution 1:
You can use subprocess.check_output
method and Popen
class though I wasn't able to chain both pipe operations. Partial solution:
from subprocess import check_output, Popen, PIPE
from shlex import split
process = Popen(split('ip -o link show'), stdout=PIPE)
output = check_output(('awk', '{print $2}'), stdin=process.stdout)
return_code = process.wait()
print(output, return_code)
So basically, awk is taking the process
standard output, and result is saved in the output
variable.
Post a Comment for "| Not Working In Subprocess.call"