[prog] Perl from cron
jennyw
jennyw at dangerousideas.com
Thu Jun 23 05:28:14 EST 2005
Short story: I'm having trouble with a Perl script running from cron --
it works great from a regular login shell, but in cron there are issues.
This is on SUSE 9.2, Perl v5.8.5.
The problem code:
use File::Basename;
use FindBin qw($RealBin);
print "RealBin: $RealBin\n";
When run from the command line, this does what you'd expect. When run
from cron, $RealBin is unitialized.
Long story: These are the first few lines of PostMaster.pl in the OTRS
package. I'm using getmail to get messages from a POP server, then
getmail is passing the message to PostMaster.pl (using an absolute
path). This works great in bash, and fails in cron with this message:
====
getmail version 4.3.10
Copyright (C) 1998-2005 Charles Cazabon. Licensed under the GNU GPL version
2.
SimplePOP3SSLRetriever:it at example.com@mail.example.com:995:
Delivery error (command PostMaster.pl 18129 error (255, fileparse(): need a
valid pathname at /opt/otrs/bin/PostMaster.pl line 26
BEGIN failed--compilation aborted at /opt/otrs/bin/PostMaster.pl line 26.))
msg 1/1 (1443 bytes), delivery error (command PostMaster.pl 18129 error
(255, fileparse(): need a valid pathname at /opt/otrs/bin/PostMaster.pl line
26
BEGIN failed--compilation aborted at /opt/otrs/bin/PostMaster.pl line 26.))
1 messages retrieved, 0 skipped
====
The error seems to be in PostMaster.pl, not getmail. The first two lines
above are the first two lines of PostMaster.pl. I added the print to see
what the difference in values was from cron v. login shell. That's how I
figured out that $RealBin is. This is what the error became once I made
the change:
Delivery error (command PostMaster.pl 18210 error (0, Use of
uninitialized value
+in concatenation (.) or string at /opt/otrs/bin/PostMaster.pl line 26.
So ... if anyone has any idea what I need to do to make FindBin happy,
please let me know.
Thanks!
Jen
More information about the Programming
mailing list