#!/usr/local/bin/perl
use Oraperl;use Mail::Mailer;
$ENV{"ORACLE_HOME"} = "/u01/app/oracle/product/8.0.6";
$ENV{"ORACLE_SID"} = "my_sid";
$ENV{"LC_TIME"} = "fr";
.....
I get the following output :
/usr/local/bin/pense_bete.pl
produced the following output:
Compilation failed in require at /usr/local/bin/pense_bete.pl
BEGIN failed--compilation aborted at /usr/local/bin/pense_bete.pl
I guess this is all a matter of setting properly the env variables.
Cron uses SH and my user uses CSH.
If I run the script manually with my CSH user, it works OK (because the
ORACLE env variables are known to him).
Any hint about a proper way to do make it work through cron ?
BEGIN {
$ENV{ORACLE_HOME} = '/u01/app/oracle/product/8.0.6'
unless $ENV{ORACLE_HOME};
$ENV{ORACLE_SID} = 'my_sid' unless $ENV{ORACLE_SID};
$ENV{LC_TIME} = 'fr' unless $ENV{LC_TIME};
}
use Oraperl;
use Mail::Mailer;
Of course, you should seriously consider converting to DBI.
--
Garry Williams
Does Oraperl.pm need those environment variables? Try:
BEGIN {
$ENV{"ORACLE_HOME"} = "/u01/app/oracle/product/8.0.6";
# ...
}
use Oraperl;use Mail::Mailer;
# ...
Alternatively, you can probably set the environment variables from your
crontab. See your system manpages for crontab(5) or such.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
> Thanks for anybody's kind piece of advice but unfortunately I get the same
> error messages...argh ! going crazy on that one ! :)
Is there more in the error message? I must admit I've never seen that exact
one.
When your cron job is run, can it find your "use"d modules in @INC? Maybe the
environment is different. Is the cron job being run as the same user? (I
normally get different errors for this problem, but your version of perl
might not be the same as mine. What is it, incidentally?)
Try a simple script that just prints @INC, and also does a "find" for the
modules you require in that list.
Regards,
Ian
Ian Boreham wrote:
> Sébastien Ferrandez wrote:
>
> Is there more in the error message?
Well the line indicated as wrong is that of the "use"s...But I guess the problem
comes from somewhere else.
> Is the cron job being run as the same user?
Yes it is.