Sunday, March 13, 2005
Perl 5.8 and FindBin
It appears that there is a bug in Perl 5.8.6's FindBin.pm whereby things
don't work so well if it doesn't have access to the current working
directory.
I picked this up trying to debug MRTG.
The program would run just fine from the command line, but not from /etc/crontab.
After playing with cron's
path and env(1)
to try and figure out what was going on, I found the following error from
cron:
Use of uninitialized value in string at /usr/local/bin/mrtg line 78.
Empty compile time value given to use lib at /usr/local/bin/mrtg line 78
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 79.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 703.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/mrtg line 703.
ERROR: Can't Execute '/rateup'
Looking on line 78 and 79 of the MRTG code I found:
use FindBin;
use lib "${FindBin::Bin}";
suggesting the problem was related to the FindBin Perl module.
Some googling lead me to a similar bug
report for RedHat Linux. Their
suggested
fix was a patch to FindBin.pm.
Since I'm not wildly keen on altering bits of my Perl installation (I forsee
problems later when I try and upgrade and have forgotten why I did it), I
decided to try for a simpler, less invasive solution. Since it appears that
the problem is related to permissions on the current working directory, and
I'm not sure what cron's
current working directory is by default, I decided to try setting it
explicitly. So I changed my cron entry from
*/5 * * * * stats /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
to
*/5 * * * * stats cd /tmp; /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
and lo and behold things started to work properly again.
Anyway, I just thought I'd share this simple solution in case anyone else
bumps their head against the same problem.
posted by guy at: 12:21 SAST |
path: /systems |
permanent link
