CentOS에서 Python 2.7로 bash 쉘을 열 수 없으며, Python 2.6.6에서 데비안에서 할 수 있습니다. 무엇이 바뀌 었습니까? 그렇지 않은 CentOS는에Python Popen은 CentOS/Red Hat에서 bash 쉘을 열 수 없습니다.
from subprocess import Popen
cmd="""cat <<'EOF'
this is
test $unchanged
EOF
"""
Popen('cat <(%s)' % cmd, shell=True, executable='/bin/bash')
데비안에서이 작품, :
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `cat <(cat <<'EOF''
의 차이점은 다음과 같습니다
- 데비안 나는 간단한 bash는 공정 대체를 시도 : Python 2.6.6,
/bin/sh
은 대시로 제공됩니다. - CenOS (레드햇) : 파이썬 2.7,
/bin/sh
는
그래서 CentOS는에 executable=/bin/bash
전혀 존경하지 않을 bash는에 의해 제공됩니다. 내가 빠진 것이 있습니까?
'cat <(% s) '% cmd'을 (를)'cmd'로 바꾸십시오. – werehuman
@werehuman bash가 시작되는지 확인하는 테스트입니다. 'sh'는 리다이렉션을 할 수는 있지만, 다른 것을 위해 필요한 치환을 처리 할 수는 없습니다. – estani
자, 인수에/bin/bash를 쓰면 어떨까요? ''Popen (''/ bin/bash ','-c ','cat <(% s) '% cmd))'' – werehuman