2
我在Raspberry Pi上有以下腳本來發送短信。它運行,如果我輸入:python tides_sms.pyRaspberry Pi Crontab腳本錯誤
問題是,我不能讓它通過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??????????")
謝謝你。簡單! – user2417713
沒問題!是的,這是一個常見的陷阱:) – hek2mgl