开发者

Use bash instead of sh as the shell of choice for python command namespace functions

I need to use a commandline that is suited to bash style, e.g.

diff x  <(cat y 开发者_运维问答| tail +2)

However, sh -c of the above line gives an error, hence commands.getoutput of the above line fails. However, bash -c of the above does what I want to get done. Can somebody suggest how to make python use bash. I understand I can get it done using subprocess, but I have a lot of command lines that I have to process and I want to use only commands.getoutput.

Thanks.


You can do commands.getoutput("bash -c 'diff x <(tail +2 y)'"), perhaps (note that cat is unnecessary).

However: commands.getoutput('tail +2 y | diff x -') doesn't require Bash.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜