当我在bash中运行脚本时,出现错误:sh: 2: Syntax error: "|" unexpected
。我不知道为什么,我想在这里使用管道,并且使用该命令的perl脚本能够工作,但我需要Python。输入(文本文件)的传递给os.system()的shell命令失败:sh:2:语法错误:“|”意外的
例子:
Kribbella flavida
Saccharopolyspora erythraea
Nocardiopsis dassonvillei
Roseiflexus sp.
脚本:
#!/usr/bin/python
import sys import os
input_ = open(sys.argv[1],'r') output_file = sys.argv[2]
#stopwords = open(sys.argv[3],'r')
names_board = []
for name in input_:
names_board.append(name.rstrip())
print(name) for row in names_board:
print(row)
os.system("esearch -db pubmed -query %s | efetch -format xml | xtract -pattern PubmedArticle -element AbstractText >> %s" % (name,
output_file))
如果用'print'替换'os.system',会得到什么?这看起来合理吗? –
你在使用什么操作系统?你读过“man esearch”,“man efetch”和“man xtract”吗? –
这个ubuntu,但这个程序是ncbi的eutilies。 – MTG