I am running the below ksh script. It makes an Oracle database connection and creates a few files. Everything works except one thing..
##########################################333
export PROGRAM_PATH=...
export SQLDIR=...
export BACKUPDIR=...
export LOGDIR=...
#!/bin/ksh
ALL_LOG_FILE=${LOGDIR}/restore_${1}_`date +%m%d%y-%H%M%S`.log
LOG_FILE=${LOGDIR}/imp_${1}_`date +%m%d%y-%H%M%S`.log
DUMPFILE=${BACKUPDIR}/"exp_${1}_${2}_${3}_${4}.dmp"
ST=`date`
if [ ! -f $DUMPFILE ]
then
echo "File $DUMPFILE does not exist" >>$LOG_FILE
ET=`date`
echo "Start Time=$ST" >>$LOG_FILE
echo "End Time=$ET" >>$LOG_FILE
exit 8
else
if [ ${1} = "group0" ]
then
sqlplus /NOLOG <<EOF
CONNECT username/password@dbcsat10
spool ${LOGDIR}/group0_disable_results.lst
@${SQLDIR}/group0_disable.sql
@${SQLDIR}/group0_truncate.sql
spool off
exit
EOF
imp username/password@database file=$DUMPFILE log=$LOG_FILE
sqlplus /NOLOG <<EOF
CONNECT username/password@database
spool ${LOGDIR}/group0_enable_results.lst
@${SQLDIR}/group0_enable.sql
spool off
exit
EOF
cat ${LOGDIR}/group0_disable_results.lst >> $ALL_LOG_FILE
cat ${LOGDIR}/$LOG_FILE >> $ALL_LOG_FILE
cat ${LOGDIR}/group0_enable_results.lst >> $ALL_LOG_FILE
fi
ET=`date`
echo "Start Time=$ST" >>$LOG_FILE
echo "End Time=$ET" >>$LOG_FILE
fi
echo "Backup File Used is $DUMPFILE" >> $LOG_FILE
mailx -r "Restore Notification"
rog_harp@domain.com < $ALL_LOG_FILE
exit 0
########################################3
There are 3 files being generated here :
group0_disable_results.lst
The file obtainted from the variable $LOG_FILE
group0_enable_results.lst
All I am trying to do is, in the 3 CAT statements, I just wanted to append the contents of each of these files into ONE file ($ALL_LOG_FILE)
The problem is when I get the email containing the attachment $ALL_LOG_FILE, I see that only the group0_disable_results.lst and group0_enable_results.lst are appended. The $LOG_FILE does not seem to CAT itself as mentioned in the statement
cat ${LOGDIR}/$LOG_FILE >> $ALL_LOG_FILE
What could be the problem ? (All the files are generated including the $LOG_FILE but just did not append)
Thanks