Parse linux command line with pipes/redirection using python
Is there any existing utility that can parse a linux command line with recognition of basic piping and redirection: '|'
, '<'
, and,开发者_运维问答 '>'
? Preferably this can be used for as parameters for a subprocess call instead of using os.system.
shlex.split()
does basic parsing, but its output cannot always be used by subprocess.Popen
like in this example:
sed -f script.sed < infile > outfile
Hotwire seems like it can do this, this web page has some information on how this works.
IPython IPipe also has a different way to do some of the same things as Hotwire.
Such a module would provide nothing that Popen with the shell=True option does not already provide.
See http://docs.python.org/library/subprocess.html#using-the-subprocess-module
It won't exist.
精彩评论