[Tutor] crontab or python mistake
Daniel McQuay
simplebob at gmail.com
Fri May 26 06:24:30 CEST 2006
hello list,
i am having a problem getting crontab to execute a python script. the script
works because i can execute it by using: python boxster_school_smtp.py from
a command line. i put a line in crontab that look like this: i know this is
not a linux mailing list but any help would be appreciated.
<snip>
*/5 * * * * root /usr/local/bin/python
/root/scripts/boxster_school_smtp.py
</snip>
now like i said the python script works by using: python my_script.py from
the command line but when i use it in crontab i get some error. here is the
error that cron gives:
<snip>
Traceback (most recent call last):
File "/root/scripts/boxster_school_smtp.py", line 19, in ?
mssg = open('mssg.txt', 'r').read()
IOError: [Errno 2] No such file or directory: ' emmssg.txt'
</snip>
the emmssg.txt file is in the /root/script directory so i don't know why it
cant find it.
thanks again,
--
Daniel McQuay
simplebob at gmail.com
boxster.homelinux.org
814.825.0847
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060526/33b1cc4d/attachment-0001.html
-------------- next part --------------
import smtplib
import os
emmssg = "/root/scripts/emmssg.txt"
smtpserver = 'mail.erieit.edu'
AUTHREQUIRED = 1
smtpuser = 'dmcquay'
smtppass = '******'
#For testing purposes only!
RECIPIENTS = ['dmcquay at erieit.edu']
#This will be used after testing
#RECIPIENTS = ['slindsay at erieit.edu','dmccann at erieit.edu','mwebster at erieit.edu',
# 'arundstedler at erieit.edu','caustin-alford at erieit.edu',
# 'dmcquay at erieit.edu']
SENDER = 'dmcquay at erieit.edu'
emmssg = open('emmssg.txt').read()
session = smtplib.SMTP(smtpserver)
if AUTHREQUIRED:
session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, emmssg)
if smtpresult:
errstr = ""
for recip in smtpresult.keys():
errstr = """Could not delivery mail to: %s
Server said: %s
%s
%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
raise smtplib.SMTPException, errstr
More information about the Tutor
mailing list