PREV INDEX NEXT    SLUUG HOME

SQL in KSH
Running SQL Scripts in Kornshell

Script Automation


SET ENTIRE ENVIRONMENT


    . /d1/d2/proj.setup # calls dept.setup calls org.setup
    # and sets and exports $PATH and $PROJDIR and others
    D=/app/proj; OUT=$D/out; ERR=$D/err; LOG=$D/log

    # set I/O (assume input handled elsewhere)
    exec 1<$OUT; alias printout='print -u1'
    exec 2<$ERR; alias printerr='print -u2'
    exec 3<$LOG; alias printlog='print -u3'
    

TEST EVERYTHING, LOG EVERYTHING


    # one test among many
    if   [[ ! -w "${D}" ]] 
    then printerr "Cannot write to directory ${D}"
         exit 2
    fi

    # typical logging
    function nowdate { date '+%Y%m%d_%H%M%S'; }
    printlog "$(nowdate) archived $DATA in $ARCHIVE"

    # function for logging exit
    function byebye
    { print "status=$status\n$0 $ARGS\nat $(nowdate)"
      exit $retcode; }
    

2002 April 10
Tom Chapin -- 314-721-3581 -- tjc@mvp.net