我在 Raspberry Pi 上有以下脚本来发送 SMS。如果我输入它就会运行:python潮汐_sms.py
问题是,我无法通过 Crontab (* * * * * /usr/bin/python /home/pi/python_files/tides_sms.py) 运行它。文件设置为:rwxr-xr-x
当我添加代码以写入文件时,该文件是通过 Crontab 创建的,但它不会发送 SMS。
任何帮助表示赞赏。
#!/usr/bin/python
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "**********************************"
auth_token = "********************************"
with open("tide_data.txt", "r") as file:
tides_array = file.read().splitlines()
tides_array.reverse()
elements = tides_array[0].split(' | ')
string=''
for element in elements:
string = '\n'.join([string, element])
client = TwilioRestClient(account_sid, auth_token)
message = client.sms.messages.create(body="Text from PI:\nTIDES" + string,
to="+44??????????",
from_="+44??????????")