CRON and packages
From Rabbi Blog
Read the extended for the story behind this. The easy fix for this was to append two back to back commands in cron:
cd /home/foca/public_html/cslog/p\&b && perl /home/foca/public_html/cslog/p\&b/scan.pl
That way when CRON runs, it switches to the proper directory and then runs the script. Script checks the local directory and finds the module.
Breakfast time :-)
Earlier that morning...
Serves me right for trying to package it up and get it out yesterday morning before going to work. I need to look into either bringing the readconfig.pm into the main script or figure out how a system handles cron runs in regards to relative/static paths. I want to avoid the end user needing to add anything to @INC if possible. The script works fine until I run the cron job on it:
Can't locate ReadConfig.pm in @INC (@INC contains: (list of paths removed) BEGIN failed--compilation aborted at /home/foca/public_html/cslog/p&b/scan.pl line 28.
So it works until you try to CRON it, which is the point of the script in the first place. I would like to stay away from needing to edit the main script for each update (i.e. hardcoding the install path).
If I check the path for @INC
-sh-3.00$ perl -e 'print join "\n", @INC' /usr/lib/perl5/5.8.6/i386-linux /usr/lib/perl5/5.8.6 /usr/lib/perl5/site_perl/5.8.6/i386-linux /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.6/i386-linux /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl
I get a return for the current directory at the end.
-sh-3.00$ perl -e 'use ReadConfig'
That works from the shell, so my guess is that the issue stems from where the system runs CRON from and attempts to run ReadConfig from that current directory.