Sunday, November 30, 2008

whatever

Say that you want to run stuff written in Perl out of cron. Cron doesn't run as you. So it doesn't inherit your finely-crafted exported shell environment:

#setup the ENV that Perl knows about:
$ENV{ORACLE_HOME}='/opt/local/instantclient_10_2';
$ENV{LD_LIBRARY_PATH}='/opt/local/instantclient_10_2';

my $sqlplus;

$sqlplus=`sqlplus user/password\@DBNAME << END
sql statements here...;
exit
END
`;

open(MAILX, "| mailx -s 'db report' user\@domain ") || die "mailx no work
\n";
print MAILX $sqlplus;
close MAILX;


In addition, remember that to edit your crontab, you may need to: export EDITOR=vi

No comments: