os.system or subprocess to pass command to shell (newbie)
python extreme newbie asking the question - I am trying to execute a command in a shell and pipe the output at the same time for filtering.

the relevent code looks like:
import os
n=raw_input("enter cmd")
os.system(n + ' | grep x')

the result is sh: Syntax error: Redirection unexpected.

It is on ubuntu, seemed like some references online mentioned this, but none I could directly associate. Seems like subprocess may help, but most examples are as of yet beyond my current understanding. Thanks for reading... =0)
os.system or subprocess to pass command to shell (newbie)
===

python extreme newbie asking the question - I am trying to execute a command in a shell and pipe the output at the same time for filtering.

the relevent code looks like:
import os
n=raw_input("enter cmd")
os.system(n + ' | grep x')

the result is sh: Syntax error: Redirection unexpected.

It is on ubuntu, seemed like some references online mentioned this, but none I could directly associate. Seems like subprocess may help, but most examples are as of yet beyond my current understanding. Thanks for reading... =0)