[prog] Perl from cron

Almut Behrens almut-behrens at gmx.net
Thu Jun 23 10:57:45 EST 2005


On Wed, Jun 22, 2005 at 12:28:14PM -0700, jennyw wrote:
> 
> 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.
> 
> (...)
> 
> (255, fileparse(): need a valid pathname at /opt/otrs/bin/PostMaster.pl line 26

It looks as if File::Basename::fileparse() is being passed an undefined
value.  Only in that case it'd complain "need a valid pathname"...

I have no clear idea why that might happen, but I have a suspicion that
it might have to do with a getcwd() lib call failing under the hood.
To check you could run the following command from your cron environment

  /usr/bin/strace -o/tmp/FindBin.trace -efile /usr/bin/perl '-MFindBin qw($RealBin)' -e1

and see what you get (in FindBin.trace, near the end)...

If that doesn't help, I would copy the FindBin.pm module (should be
/usr/lib/perl5/5.8.5/FindBin.pm) into some temporary directory (so you
can edit it without messing with the rest of the system), and put a
few debugging print()s into the code, directly before 'fileparse' gets
called (there are exactly two places).  Then make sure the modified
FindBin.pm is in fact being loaded by pointing the env var PERL5LIB to
the directory where that FindBin.pm resides.
The FindBin.pm code is rather short and not too complex, so you have
a realistic chance to figure out where things go wrong...

Good luck,
Almut



More information about the Programming mailing list