If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > CAT a file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-02-07, 12:14
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
CAT a file

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
Reply With Quote
  #2 (permalink)  
Old 07-02-07, 18:24
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Export LOG_FILE?!
Reply With Quote
  #3 (permalink)  
Old 07-03-07, 08:48
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
Thanks, but when I do a

mailx -r "Restore Notification" rog_harp@domain.com < $LOG_FILE

(instead of mailx -r "Restore Notification" rog_harp@domain.com < $ALL_LOG_FILE)

I get the $LOG_FILE in my email. Hence I am not sure as to why I need to EXPORT LOG_FILE ?
Reply With Quote
  #4 (permalink)  
Old 07-03-07, 18:15
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
I guess it's because a new shell executes the cat command that expects an argument, the filename. Thus the filename is a property of the program executed by the forked shell. The mail command is also executed by a new shell but expects an inputstream and that is provided by the parentshell.
Could it be something like this?

Regards
Reply With Quote
  #5 (permalink)  
Old 07-09-07, 16:53
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Code:
cat ${LOGDIR}/group0_disable_results.lst >> $ALL_LOG_FILE
cat $LOG_FILE                            >> $ALL_LOG_FILE
cat ${LOGDIR}/group0_enable_results.lst  >> $ALL_LOG_FILE
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On