How would I do the following subprocess command in python?
$ ps aux|grep python
>>> subprocess.check_output(['ps', 'aux', 'grep', 'python']) ?
How would I do the following subprocess command in python?
$ ps aux|grep python
>>> subprocess.check_output(['ps', 'aux', 'grep', 'python']) ?
You can do the following:
ps = subprocess.Popen(('ps', 'aux'), stdout=subprocess.PIPE)
output = subprocess.check_output(('grep', 'python'), stdin=ps.stdout)
ps.wait()
print output