Hi,
I have a shell script which fetches the MRP status and the LAG status.
When I execute it manually like, sh <script_name>, it fetches the output as expected, but when I schedule through crontab, it's not working as expected.
Any help would be really appreciated.
Here is the code snippet:
for pass in $(cat /u/oracle/nagy/passwd.txt)
do
tns=`cat /u/oracle/nagy/passwd.txt | grep $pass | cut -d"@" -f2`
#env=`tnsping $tns | grep HOST | cut -d"-" -f2`
#env=$(echo ${env} | tr '[a-z]' '[A-Z]')
env=PROD
echo "Pass is: $pass"
if [[ "$tns" = "DR514" ]]; then
echo "I am in IF Loop of LAG Check"
status=`sqlplus -s "${pass} as sysdba" <<~EOF
echo "After SQLPLUS in IF LAG CHECK"
#set pages 999 long 90000 heading off
SET MARKUP HTML ON SPOOL ON
#spool /tmp/$FN
echo "Spooling IF LAGCHECK"
#@/u/oracle/nagy/check_loggap_DR514.sql
#SET MARKUP HTML OFF SPOOL OFF
#spool off
spool /tmp/MRP_$tns.log
echo "Spooling ID MRP"
@/u/oracle/nagy/mrp.sql
spool off
exit;
EOF`
else
echo "I am in ELSE loop of LAG Check"
status=`sqlplus -s "${pass} as sysdba" <<~EOF
echo "After SQLPLUS in ELSE LAGCHECK"
set pages 999 long 90000 heading off
#SET MARKUP HTML ON SPOOL ON
#spool /tmp/$FN
echo ""Spooling ELSE LAGCHECK"
#@/u/oracle/nagy/check_loggap.sql
#SET MARKUP HTML OFF SPOOL OFF
#spool off
spool /tmp/MRP_$tns.log
echo "Spooling ELSE MRP"
@/u/oracle/nagy/mrp.sql
spool off
exit;
EOF`
fi
done
The issue is, it's not getting into the line "status=`sqlplus -s "${pass} as sysdba" <<~EOF" at all, when I schedule it through cron, but manually it works.
Following is the sample output, when it's scheduled through crontab.
Pass is: sys/pr0t3ctSYS@DR508
I am in ELSE loop of LAG Check
Pass is: sys/pr0t3ctSYS@DR509_DG
I am in ELSE loop of LAG Check
Pass is: sys/pr0t3ctSYS@DR510
I am in ELSE loop of LAG Check
Pass is: sys/pr0t3ctSYS@DR511
I am in ELSE loop of LAG Check
Pass is: sys/pr0t3ctSYS@DR513
I am in ELSE loop of LAG Check
Pass is: sys/pr0t3ctSYS@DR514
I am in IF Loop of LAG Check
Please note that it's an AIX box.
Please help me out to get this rid of the weird situation and let me know if anything to be corrected in the script.