Results 1 to 5 of 5

Thread: CAT a file

  1. #1
    Join Date
    Feb 2004
    Posts
    143

    Unanswered: 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

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Export LOG_FILE?!

  3. #3
    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 ?

  4. #4
    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

  5. #5
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •