Re: Perl app won't compile /run from cron
by haukex (Archbishop) on May 23, 2018 at 21:48 UTC
|
Try the command perldoc -l Image::Grab to show you where the module got installed, I'm guessing that that path isn't one of the @INC directories listed at the top of your post. Setting the right PATH isn't always enough if you've got custom entries added to @INC via something like the PERL5LIB environment variable, because then that environment variable needs to be set in the environment that cron provides to the programs it runs. I'm still just guessing, but probably that isn't the case and the environment provided by cron is different from the one you have on the command line. For example, are you using local::lib? If you want to see the difference, try running this command from both the command line and from a crontab entry: perl -le 'die "$ENV{PERL5LIB} @INC\n"'
If those are different, then it depends on how you're changing @INC for the best way to solve this. If you could report back with the results of the above, we can probably help more.
| [reply] [d/l] [select] |
|
Hi
I tried perldoc -l Image::Grab but I don't have perldoc installed.
I am not using local::lib.
I used the cron commmand
* * * * * /usr/bin/perl /home/user/perl_script.pl 1 2>&1 | /usr/bin/
+logger -t test_cron
to get the compiler error output from syslog.
| [reply] [d/l] [select] |
|
I am not using local::lib.
Based on the pathname ~/perl5/lib/perl5 and that you say you used cpan to install the module, I'm pretty sure you are using local::lib. The cpan client, when run without sudo, will usually detect that it doesn't have permissions to write to the system directories and autoconfigure to use local::lib. If you check your .profile or .bashrc files, you should see variables like PERL_LOCAL_LIB_ROOT and PERL5LIB being set there, these would have been added there by local::lib, and as I said those are the variables that are probably missing from the environment that cron provides, hence my suggestion to try and set PERL5LIB explicitly.
I tried perldoc -l Image::Grab but I don't have perldoc installed.
Well, you could do sudo apt-get install perl-doc, but did you try dave_the_m's suggestion, which should work even without perldoc? I also made a few other suggestions and asked a few questions above as well as here.
| [reply] [d/l] [select] |
|
I tried perldoc -l Image::Grab but I don't have perldoc installed.
locate Image/Grab.pm
| [reply] [d/l] [select] |
Re: Perl app won't compile /run from cron
by dave_the_m (Monsignor) on May 23, 2018 at 21:49 UTC
|
Perl usually gets extra module paths from the PERL5LIB environment variable rather than PATH. So that would be the first thing to look at.
Also, its possible that cron and the terminal are running as different users (and so with different file/directory permissions), or are using different versions of the perl executable. You can see where the module is being loaded from the terminal by using:
$ perl -le 'require Image::Grab; print $INC{"Image/Grab.pm"}'
/some/path/lib/Image/Grab.pm
If that path isn't in the list of paths in the cron error message, that's another place to investigate.
Dave. | [reply] [d/l] |
|
| [reply] [d/l] [select] |
Re: Perl app won't compile /run from cron
by choroba (Cardinal) on May 23, 2018 at 22:20 UTC
|
Perl modules are searched for in @INC, not $ENV{PATH}. To set @INC, you can use the $PERL5LIB environment variable, or specify the directories with the -I options to perl (see perlrun).
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
Re: Perl app won't compile /run from cron
by haukex (Archbishop) on May 24, 2018 at 12:37 UTC
|
| [reply] |
Re: Perl app won't compile /run from cron
by Random_Walk (Prior) on May 24, 2018 at 08:44 UTC
|
It looks like you are missing the path to your library in your @INC array within Perl. You can add a line to your script to explicitly use the library directory where Image::Grab is installed.
use lib '/var/local/perl-site/';
Or where ever it may be. It is strange that it is not in a standard system patch though if it is installed with cpan. Do you know the directory where Grab.pm is installed?
Cheers, R.
Pereant, qui ante nos nostra dixerunt!
| [reply] [d/l] [select] |
|
darren@trackcam3:~ $ find ~/ -name Grab
/home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/lib/Image/Grab
/home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/lib/Image/Grab
/home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/lib/auto/Image/G
+rab
/home/darren/.cpan/build/Image-Grab-1.4.2-gwMQYz/blib/arch/auto/Image/
+Grab
/home/darren/perl5/lib/perl5/arm-linux-gnueabihf-thread-multi-64int/au
+to/Image/Grab
/home/darren/perl5/lib/perl5/Image/Grab
Image::Magick is installed here:
/usr/lib/arm-linux-gnueabihf/perl5/5.24/Image/Magick
/usr/lib/arm-linux-gnueabihf/perl5/5.24/auto/Image/Magick
This is a headless server so having libraries splattered around isn't helpful.
Looking back at my notes, CPAN installed the modules in my home dir. The Ubuntu packages were installed in /usr.
| [reply] [d/l] [select] |
|
"This is a headless server so having libraries splattered around isn't helpful"
Then don't do that. If you are using the system perl and a package is available in apt, use that, otherwise you need to install things in the right place (sudo cpanm Image::Grab), or (as detailed in other replies you already have) specify the correct paths for your cron jobs for where you have installed things.
| [reply] [d/l] |
|
|
|
|
Re: Perl app won't compile /run from cron
by marto (Cardinal) on May 24, 2018 at 08:46 UTC
|
You've posted this many times now, I suspect you are refreshing your screen and resubmitting a form. Your first post has responses.
| [reply] |
|
I already messaged him yesterday, telling him not to refresh.
I think it's deliberate.
| [reply] |
|
Hi
I have been refreshing my screen looking for responses. I had no idea a refresh caused a resubmit. I have only just found this message and the responses.
I don't visit this site very often so still learning its quirks.
| [reply] |
|
| [reply] |
Re: Perl app won't compile /run from cron
by dazz (Beadle) on May 24, 2018 at 09:43 UTC
|
Hi
The problem I have is exactly the same as this link
https://stackoverflow.com/questions/17194632/perl-cant-find-module-when-run-from-cron-daily
I have found the Image::Grab module at
~/perl5/lib/perl5/Image
The directory:
:/usr/lib/perl5
is empty and so is
:/usr $ ls lib/perl5/
I am running Rasbian on a Raspberry Pi. I don't know what files are supposed to be where.
| [reply] [d/l] [select] |
|
Sounds like the module was installed with local::lib, which should normally set its environment variables in .profile/.bashrc. Anyway, did you try the solutions suggested in that link? For example prepending PERL5LIB=/home/pi/perl5/lib/perl5 to the command in your crontab?
| [reply] [d/l] [select] |
|
Hi
The "missing" modules were installed with CPAN that has chosen to put them in my home dir.
| [reply] |
|
| [reply] |