我正在使用 python 命令模块运行 mongoimport 命令
status = utilities.execute(mongoimport)
在实用程序.py
def execute(command):
if not command:
return (-1, 'command can not be empty or null')
return commands.getstatusoutput(command)
当我运行它时,我看到错误为
sh: Syntax error: ";" unexpected
我看到文档说:
commands.getstatusoutput(cmd)
Execute the string cmd in a shell with os.popen() and return a 2-tuple (status, output). cmd is actually run as { cmd ; } 2>&1, so that the returned output will contain output or error messages
我该如何解决这个问题才能运行这个命令?