我想执行这个linux命令
"cat cflow_image.py | mailx -s "CFLOW Copy" 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