#!/bin/ksh # # Author: Mohit Dubey # Visit http://www.geocities.com/md_seraphin for more goodies! # # This program is distributed under the GNU Public License Version 2 # with the additional privisio that the original author's name and # contact details must be retained as-is in any modified or copied # versions of this program. # if [[ $# -ne 1 ]] then printf "\nUsage: %s \n\n" ${0##*/} exit fi if [[ ! -f $1 || ! -r $1 ]] then printf "\nInput SQL script [%s] is not accessible!\n\n" $1 exit fi inSql=$1 printf "\nSchema login [uname/pass@db]: " read ORA_LOGIN foo printf "\n" if [[ -z $ORA_LOGIN ]] then printf "No credentials supplied!\n\n" exit fi printf "Validating credentials..." if $(sqlplus -s $ORA_LOGIN <<-Eosql | /usr/xpg4/bin/grep -q ORA- exit; Eosql ) then printf "invalid credentials!\n\n" exit; fi printf "done\n" INPIPE=/tmp/inPipe.$$ OUTPIPE=/tmp/outPipe.$$ /bin/rm -f $INPIPE && mknod $INPIPE p /bin/rm -f $OUTPIPE && mknod $OUTPIPE p sqlplus -s $ORA_LOGIN <$INPIPE 1>$OUTPIPE 2>&1 & printf "Spawned execute server with PID %s\n" $(jobs -l %1 | nawk '{printf "%s",$3;}') cat $OUTPIPE | sed '/^$/d' & printf "Spawned output server with PID %s\n" $(jobs -l %2 | nawk '{printf "%s",$3;}') printf "Submitting [%s] to execute server...\n\n" $inSql nawk -v inPipe=$INPIPE \ '{ printf "%s\n",$0 > inPipe; } END{ printf "exit\;\n" > inPipe; }' $inSql wait printf "\nSpawned processes shut down\n\n" /bin/rm -f $INPIPE $OUTPIPE