1

我在 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 `('

任何帮助将不胜感激!

4

2 回答 2

4

<(...)POSIX 中未定义进程替换 using 。你应该使用 bash 之类的东西。您可以通过executable="/bin/bash"使用 bash 来运行命令。

subprocess.run('cat <(echo hoo)', shell=True, executable="/bin/bash")
于 2017-10-17T01:35:11.467 回答
2

被调用的默认 shell 是/bin/sh,它不支持进程替换<(...)语法),这是一个 Bash 特性。

于 2017-10-17T01:29:04.580 回答