开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜