> I have a ksh script which calls a Perl script using /usr/lib/sendmail
> to send mail. When I run the Perl script from the command line it seems
> to use my /etc/mail/sendmail.cf but when running the Perl script
> through the ksh script in cron it does not. I can tell this because the
> return path is not set properly when the script runs from cron. Here is
> the ksh script:
> #!/usr/bin/ksh
> #set -x
> cd /export/home2/spiderman/queue
> chmod 777 *.email
> PETER=`ls -1 [0-9]*email | wc -l `
> if [ $PETER -ne 0 ]
> then
> for i in `ls -1 [0-9]*email`
> do
> MDATE=`date +%d%b%y-%H%M%S`
> LOGFILE=/export/home2/spiderman/logs/PRO-email.sent.log
> echo " PROFILE MAILER START" >> $LOGFILE
> echo " ============================================== " >> $LOGFILE
> cat $i >> $LOGFILE
> /usr/bin/perl $i 2>> $LOGFILE
> echo " ============================================== " >> $LOGFILE
> echo " PROFILE MAILER SENT" >> $LOGFILE
> rm $i
> done
> fi
> Here is an example of the Perl script:
> #!/usr/bin/perl
> open(SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Can't open
> sendmail: $!\n";
> print SENDMAIL << "EOF";
> Subject: Blah Blah
> Some text
> Thank You
> EOF
> close(SENDMAIL) or warn "sendmail did not close nicely";
> Any ideas why this is not getting the proper sendmail.cf through cron?
/usr/lib/sendmail will certainly use its sendmail.cf file.
The error must be somewhere else.
Consider this version:
cd /export/home2/spiderman/queue
MDATE=...
LOGFILE=...
# turn shell expansion on in case it was off
set +f
for i in [0-9]*email
do
# ensure this is a readable file:
[ -f "$i" ] || continue
# probably not needed:
# chmod 777 "$i"
echo " PROFILE MAILER START"
echo " ============================================== "
cat "$i"
/usr/bin/perl "$i" 2>&1
# sendmail is CPU-intensive - give the system a breath
sleep 1
rm -f "$i"
echo " ============================================== "
echo " PROFILE MAILER SENT"
done >> $LOGFILE
exit 0
If I understand right, the script should execute whatever
it finds with a /usr/bin/perl interpreter.
A bit strange, and a bit risky...
What do you mean by "return path"?
--