我在 Python 3.5 中运行了这个:
import subprocess
subprocess.run(
'some_command --option <(zcat some_file_1.gz) <(zcat some_file_2.gz)',
shell=True
)
得到这个错误:
/bin/sh: -c: line 0: syntax error near unexpected token `('
任何帮助将不胜感激!
我在 Python 3.5 中运行了这个:
import subprocess
subprocess.run(
'some_command --option <(zcat some_file_1.gz) <(zcat some_file_2.gz)',
shell=True
)
得到这个错误:
/bin/sh: -c: line 0: syntax error near unexpected token `('
任何帮助将不胜感激!
<(...)
POSIX 中未定义进程替换 using 。你应该使用 bash 之类的东西。您可以通过executable="/bin/bash"
使用 bash 来运行命令。
subprocess.run('cat <(echo hoo)', shell=True, executable="/bin/bash")
被调用的默认 shell 是/bin/sh
,它不支持进程替换(<(...)
语法),这是一个 Bash 特性。