Script works manually, but not as cron job?

Script works manually, but not as cron job?

Posted by: Skybly
Posted on: 2003-12-29 05:58:00

Hello,

I have a MovableType blog installed on my webspace, as well as the Pop2Blog plugin which checks a POP mailbox for emails and posts them to the blog. The plugin seems to be working perfectly as long as I execute the script manually, but as soon as I call it using a cron job, it doesn't work.

This is the content of my crontab file:

0 3 * * * perl /home/username/awstats/awstats_buildstaticpages.pl -config=fereveldir -update -awstatsprog=/home/username/awstats/awstats.pl -dir=/home/username/fereveldir.pointy-ears.net/awstats/
30 * * * * perl /home/username/the-witch/pop2blog.pl

(the first line rebuilds a statistics page, never had any problems with it)

With that setup, it emails me the following message every time the cron job is executed:
"ERROR: Don't know which folder I should open: no name.
Can't call method "messages" on an undefined value at /home/username/the-witch/pop2blog.pl line 52."

But when I just copy & paste the very same command I have in my crontab file, it executes perfectly. I'd appreciate any ideas on why this is happening, I haven't used cron jobs much before but I didn't think there would be any difference from executing scripts manually or automatically...? Thanks!

Re: Script works manually, but not as cron job?

Posted by: ardco
Posted on: 2003-12-29 15:33:00

My guess is a variable not being set by/in cron. Below's an excerpt from man 5 crontab, and here's a previous forum discussion. Any idea what line 52 is?

Re: Script works manually, but not as cron job?

Posted by: Skybly
Posted on: 2003-12-29 18:58:00

Aha! I poked around in the script a bit and found that one Perl module it uses requires the environment variable MAIL to be set. It works now, thanks alot! :)

Tags: cron jobawstatsundefined valuepointy earswitchemailsperlblogcrontabscript workswebspacechecksstatistics