如何将脚本中的变量(缺少文件)$file传递到正文消息中的python电子邮件脚本中。 script.sh
#!/bin/bash
file = abc.txt
echo "the following" ${file} "are missing"
pythonEmail.py
pythonemal.py
#!/usr/bin/python
import smtplib
sender = 'me@test.com'
receivers = ['you@test.com']
message = """From: myself<me@test.com>
To: you@test.com'
Subject: missing files
$file
"""
try:
smtpObj = smtplib.SMTP("localhost")
smtpObj.sendmail(sender, receivers, message)
print ("Successfully sent email")
except SMTPException:
print ("Error: unable to send email")
这并不比@Haxiel评论的更多:
script.sh:
pythonEmail.py:
相关问题 更多 >
编程相关推荐