我想执行这个linux命令为什么这个linux命令在使用python执行时不工作?
“cat cflow_image.py | mailx -s”CFLOW复制“foo @ .foo.com”。我的要求是在python脚本中使用此命令。我正在使用subprocess模块来实现此目的。
这是我做这一段代码,
def send_mail(mailid):
# This is mail the testbed info to the user
mailid = args.mailID
print "* INFO file will be sent to your mailid *"
subprocess.call("cat info.txt | mailx -s \"DEVSETUP\" {0}").format(mailid)
以下是错误执行时,
Traceback (most recent call last):
File "dev-installer.py", line 243, in <module>
send_mail(args.mailID)
File "dev-installer.py", line 204, in send_mail
subprocess.call("cat info.txt | mailx -s \"DEVSETUP\" {0}").format(mailid)
File "/sw/packages/python/2.7.4/lib/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/sw/packages/python/2.7.4/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/sw/packages/python/2.7.4/lib/python2.7/subprocess.py", line 1308, in _execute_child
相关:https://stackoverflow.com/questions/295459/how-do-i-use-subprocess-popen-to-connect-multiple-processes-by-pipes – OozeMeister
你尝试调用子以及参数列表 – c24b