【发布时间】:2019-12-04 12:08:10
【问题描述】:
我正在尝试使用子进程在对 2 个文件进行排序后加入它们。但我收到以下错误。是否尝试转义“/”,也没有帮助。
cmd = "join --nocheck-order -t/: <(sort file1) <(sort file2)"
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shellresult = proc.communicate()
print result
('', '/bin/sh: 1: Syntax error: "(" unexpected\n')
【问题讨论】:
-
posix 标准的
/bin/sh无法理解<(command)语法。需要使用 bash、zsh、ksh93 或其他 shell 来运行它。
标签: python unix subprocess