Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Newbie]: Perl and Cron

1 view
Skip to first unread message

Sébastien Ferrandez

unread,
Oct 25, 2000, 3:00:00 AM10/25/00
to
When trying to launch the script below through cron :

#!/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 ?


Garry Williams

unread,
Oct 25, 2000, 3:00:00 AM10/25/00
to
On Wed, 25 Oct 2000 16:22:18 +0200, Sébastien Ferrandez
<sferr...@wineandco.com> wrote:
>When trying to launch the script below through cron :
>
>#!/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";
>.....

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

Rafael Garcia-Suarez

unread,
Oct 25, 2000, 3:00:00 AM10/25/00
to
Sébastien Ferrandez wrote in comp.lang.perl.misc:

>When trying to launch the script below through cron :
>
>#!/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 ?

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/

Sébastien Ferrandez

unread,
Oct 25, 2000, 3:00:00 AM10/25/00
to
Thanks for anybody's kind piece of advice but unfortunately I get the same
error messages...argh ! going crazy on that one ! :)

Ian Boreham

unread,
Oct 25, 2000, 8:02:51 PM10/25/00
to
Sébastien Ferrandez wrote:

> 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


Sébastien Ferrandez

unread,
Oct 26, 2000, 3:00:00 AM10/26/00
to

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.

0 new messages