Error in script

March 19, 2009 at 09:59:49
Specs: Windows XP
#!/bin/ksh
. $HOME/cron_profile
set -x >> /tmp/xlog

MAIL="mail"
#INPUT_FILE=$TLM_HOME/logs/batchlogs/FASTLOADssrdep
INPUT_FILE=/usr/appl/ssr/apps/ssrdep/pipe_testing/temp
LOG_FILE=$TLM_HOME/logs/dep_fastload.log
#Getting Month and Date from system time
CUR_DATE="$(date "+%b %d")"
#Checking for the 'INVALID' string for current date in FASTLOAD.ssrdep File
grep -w 'INVALID' $INPUT_FILE |grep "$CUR_DATE"
if [ $? -eq 0 ]
then
echo "$CUR_DATE :" >> $LOG_FILE
echo "`grep -l 'INVALID' $INPUT_FILE`" >> $LOG_FILE
echo "Found 'INVALID'string in FASTLOAD logs.Please check $LOG_FILE" |mailx -s "DEP 2.6 Found 'INVALID' string in FASTLOA
D logs" $MAIL
else
echo "$CUR_DATE : INVALID STRING IS NOT FOUND" >> $LOG_FILE
fi

Above is my script. if i execute this normally, it executes and triggesr mail 2 me, but if i shedule through crontab it not getting executed and through an error
`fi' unexpected @ syntax error at line 25
kindly help to clear it out


See More: Error in script

Report •


#1
March 19, 2009 at 10:56:38
When a script runs from the command line, but errors out from cron, normally, it's because cron's environment is different from a normal user's environment. A big offender is the PATH environmental variable is set differently.

In your case, probably $HOME isn't going to be the same from cron as when you run it with your user id:

. $HOME/cron_profile

Also, you have done well to include your shell, #!/bin/ksh, because on most all non-Linux *nix systems the default cron shell is !#/bin/sh.


Report •
Related Solutions


Ask Question