Python的POPEN无法打开的CentOS /红帽的bash shell [英] Python Popen can't open bash shell in CentOS/Red Hat
本文介绍了Python的POPEN无法打开的CentOS /红帽的bash shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法打开CentOS的是bash shell与Python 2.7,我能够在Python 2.6.6的Debian这样做。发生了什么变化?
I can't open a bash shell in CentOS with python 2.7, I'm able to do so in python 2.6.6 Debian. What has changed?
我试过一个简单的bash进程替换:
I tried a simple bash process substitution:
from subprocess import Popen
cmd="""cat <<'EOF'
this is
test $unchanged
EOF
"""
Popen('cat <(%s)' % cmd, shell=True, executable='/bin/bash')
在Debian的这部作品,在CentOS的它不:
In Debian this works, in CentOS it doesn't:
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `cat <(cat <<'EOF''
的区别是:
- 的Debian :Python的2.6.6,
/ bin / sh的
由破折号提供 - CenOS (红帽):Python的2.7,
/ bin / sh的
由庆典提供
- Debian: Python 2.6.6,
/bin/sh
is provided by dash. - CenOS (Red Hat): Python 2.7,
/bin/sh
is provided by bash
因此,在CentOS的在 =可执行文件/ bin中/庆典
不是的荣幸的。
我缺少的东西吗?
So in CentOS the executable=/bin/bash
is not being honored at all.
Am I missing something?
推荐答案
如果你写的参数/斌/ bash的?
What if you write /bin/bash in arguments?
Popen(['/bin/bash', '-c', 'cat <(%s)' % cmd])
这篇关于Python的POPEN无法打开的CentOS /红帽的bash shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文