- 论坛徽章:
- 0
|
shell 1
#-------------------------------------------------------------------------
# Program Name.........SUBMIT System
# Filename.............submit
# Version..............2.00
# Version Date.........January 12, 1999
# Author...............Kevin M. Hulse
#----------------------------------------------------------------------------
/abbdaemon/dostounix $1
hostappf=/abbdaemon/`hostname`.va
#
#----------------------------------------------------------------------------------
# Change, Kevin M. Hulse, Nov. 26, 1996
#
# Error messages in the submit.log file were not showing the program name
# requested (invalid program name error message). This was because the
# program variable was not assigned. Use read to get the requested program
# name from the file, then grep the valid application list file (.va) to
# determine if it is a valid program name.
#
#program=`fgrep -x -f $hostappf $1`
#----------------------------------------------------------------------------------
read -r program < $1
grep $program $hostappf
if [ "$?" -eq 0 ]
then
echo " "
echo "*****************************************************************"
echo Start: $program, input=$1, pid= $$, `date`
echo "*****************************************************************"
echo " "
#--------------------------------------------
# Get the output file names.
#--------------------------------------------
output=`grep ssoutputname $1 | awk -F= '{ print $2 }'`
output2=`grep ssoutput2name $1 | awk -F= '{ print $2 }'`
output3=`grep ssoutput3name $1 | awk -F= '{ print $2 }'`
#-------------------------------------------------------------
# Get the client/server output file transfer directory
#-------------------------------------------------------------
commdir="`echo $output | /abbdaemon/getpath`"
#----------------------------------------------------
# See if we need to change our working directory.
# If so, we need to move our input file there also.
#----------------------------------------------------
workdir=`grep ssworkdir $1 | awk -F= '{ print $2 }'`
if [ -n "$workdir" ]
then
#--------------------------------------------------
# See if we need to create the directory we want
# to work out of.
#--------------------------------------------------
if [ -d "$workdir" ]
then
#--------------------------------------------------
# Move input file to the requested working dir.
#--------------------------------------------------
mv $1 "$workdir"/$1
if [ "$?" -eq 0 ]
then
echo . Moved input file $1 to directory $workdir
else
echo . Error Moving input file $1 to directory $workdir
fi
#--------------------------------------------------
# Change directory to the requested working dir.
#--------------------------------------------------
cd "$workdir"
if [ "$?" -eq 0 ]
then
echo . Changed Directory To: $workdir
else
echo . Error Changing Directory to $workdir
fi
else
#--------------------------------------------------------
# Error message, directory does not exist.
# Send error message in user output file back to user.
#--------------------------------------------------------
echo "submit-shell-Error:" > $1.out1
echo "Submit_Shell will not execute $program" >> $1.out1
echo "Because the data directory $workdir \c" >> $1.out1
echo "does not exist.\n\n" >> $1.out1
echo "Check the contract number input \c" >> $1.out1
echo "on the Submit UserData Screen.\n" >> $1.out1
echo "If a new contract number needs \c" >> $1.out1
echo "to be added to the system," >> $1.out1
echo "Contact Engineering Systems \c" >> $1.out1
echo "& Automation Help Line, x-4357" >> $1.out1
#--------------------------------------------------------
# Error message, directory does not exist.
#--------------------------------------------------------
echo "Aborting $program because directory $workdir \c"
echo "does not exist.\n\n"
cp $1.out1 $output
ls -al $1.out1
ls -al $output
chmod 777 $output
rm $1*
exit
fi
fi
#--------------------------------------------
# Remove the system info from the file.
#--------------------------------------------
cat $1 | /abbdaemon/stripsysteminfo > $1.tmp
mv $1.tmp $1
#--------------------------------------------
# Execute the program.
#--------------------------------------------
$program $1 $1.out1 $1.out2 $1.out3
echo " "
echo "******************************************************************"
echo Stop: input= $1, program= $program, pid= $$, `date`
echo "******************************************************************"
echo " "
#
#----------------------------------------------------------------------------------
# Change: Kevin M. Hulse, August 22, 1997
#
# temp prefix was added to output file name so Submit/NT would not try to retrieve
# the file before the rename occurs. Submit/NT searches for all files with the
# name matching the users Novell UserName, and was grabbing the files before they
# were fully written or renamed.
#----------------------------------------------------------------------------------
tempPrefix="temp"
echo output=$output
echo commdir=$commdir
if [ -f "$1".out1 ]
then
cp $1.out1 ${commdir}${tempPrefix}$1.out1
#echo $1.out1 copied to ${commdir}${tempPrefix}$1.out1
sleep 2
mv ${commdir}${tempPrefix}$1.out1 $output
sleep 1
#echo ${commdir}${tempPrefix}$1.out1 RENAMED TO $output
ls -al $output
chmod 777 $output
fi
if [ -f "$1".out2 ]
then
cp $1.out2 ${commdir}${tempPrefix}$1.out2
#echo $1.out2 copied to ${commdir}${tempPrefix}$1.out2
sleep 2
mv ${commdir}${tempPrefix}$1.out2 $output2
sleep 1
#echo ${commdir}${tempPrefix}$1.out2 RENAMED TO $output2
ls -al $output2
chmod 777 $output2
fi
if [ -f "$1".out3 ]
then
cp $1.out3 ${commdir}${tempPrefix}$1.out3
#echo $1.out3 copied to ${commdir}${tempPrefix}$1.3
sleep 2
mv ${commdir}${tempPrefix}$1.out3 $output3
sleep 1
#echo ${commdir}${tempPrefix}$1.3 RENAMED TO $output3
ls -al $output3
chmod 777 $output3
fi
rm $1*
else echo "input= $1, *** invalid program name= $program ***"
fi
shell 2
#! /bin/ksh
-
echo locald starting, pid=$$, at `date`
cd /abbdaemon
startdate="$(date +%d)"
#
#--------------------------------------------------------------------------------
# Assign the Submit Command File based on the server name
#--------------------------------------------------------------------------------
submitShell="submit"
if [ "`hostname`" = 'larry' ]
then
submitShell="icadsubmit"
fi
#
if [ "`hostname`" = 'curly' ]
then
submitShell="icadsubmit"
fi
#
if [ "`hostname`" = 'lucy' ]
then
submitShell="icadsubmit"
fi
#
#------------------------------------------------
# function SubmitFilesInDir
#------------------------------------------------
function SubmitFilesInDir {
echo $1 | grep -i -s 'cpuser/in' > /dev/null
if [ "$?" -eq 0 ]
then
#
#--------------------------------------------------------
# Process user data files from oldest to newest.
#--------------------------------------------------------
ls -1 -t -r $1 > locald.wrk
while read userfile
do
echo $userfile | grep -i -s 'KMH01' > /dev/null
if [ "$?" -eq 0 ]
then
cp $1/$userfile /u/kmh01/$userfile
fi
#---------------------------------------------------
# change: 03/09/99, Kevin Hulse
# Test the file size, if it is greater than zero,
# process the file.
#---------------------------------------------------
#if test -s $1/$userfile
tr -d \^M <$1/$userfile >/dev/null
if [ "$?" -eq 0 ]
then
mv $1/$userfile /u/cpuser/$userfile
if [ "$?" -eq 0 ]
then
chown cpuser /u/cpuser/$userfile
chmod 770 /u/cpuser/$userfile
if [ -s /u/cpuser/$userfile ]
then
echo `hostname` Processing $userfile at `date`
su - cpuser << eof
/abbdaemon/$2 $userfile >> submit.log 2>&1 &
eof
else
rm -f /u/cpuser/$userfile
fi
fi
fi
done < locald.wrk
else
echo "Error - SubmitFilesInDir: We are not looking at the cpuser/in file system"
fi
return 0
}
#
#------------------------------------------------------------------------------
# "MAIN" Routine
#------------------------------------------------------------------------------
while [ "$startdate" = "$(date +%d)" ]
do
SubmitFilesInDir /u/cpuser/in $submitShell
# Delay Loop for x seconds
sleep 3
done
rm -f ./archive/locald.*
cp locald.log ./archive/locald.$(date +%d%h%y)
# cp /u/cpuser/submit.log ./archive/submit.$(date +%d%h%y)
rm locald.log
rm -f /u/cpuser/* |
|