#!/bin/sh # # --------- # AiresTask # --------- # # This is a sh script to spool new Aires tasks. # # Written by S. J. Sciutto, La Plata 1996, 1997; Fermilab 1999; # La Plata 2000. # # Last modification: 18/Nov/2001. # # Usage: # # AiresTask [-n] [-s sp_no] [-p prog_var_name] { taskname | ifile } \ # [ {taskname | ifile} ... ] # # If a taskname is given, then an input file taskname.inp is assumed. # Wildcard characters are accepted. # ############################################################################### # # Setting predefinded constants. # AiresSet="${HOME}/.airesrc" if [ -f $AiresSet ] then . $AiresSet else # # .airesrc file does not exist, trying in default bin directory. # AiresSet="${HOME}/aires/current/bin/airesrc" if [ -f $AiresSet ] then . $AiresSet else # # Have no other ideas about the setting file. # echo echo Cannot find internal script file! echo exit fi fi # Other predefined parameters are set after knowing the spool number. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # echo if [ $# -lt 1 ] then echo "Usage: AiresTask [-n] [-s sp_no] [-p prog_var_name] "\ "{ taskname | inputfilename } [ ... ]" echo exit fi # launch=TRUE # # Checking the existence of qualifiers. # for i in 1 2 3; do case "_$1" in _-s) spoolnumber=$2 shift 2 ;; _-p) progvar=$2 shift 2 ;; _-n) launch= shift ;; _-*) echo "Usage: AiresTask [-n] [-s sp_no] [-p prog_var_name] "\ "{ taskname | inputfilename } [ ... ]" echo exit ;; esac done # # Completing predefined parameters. # . ${Airesbindir}/AiresSetParams # # Checking the correct setting of program variable. # if [ "_$progvar" = "_" ] then progvar="program$spoolnumber" else pp="\$$progvar" eval pp=$pp if [ "_$pp" = "_" ] then echo Program variable \"$progvar\" is undefined. echo "No task(s) spooled." exit fi fi # # Processing the input file(s). # ppid=$$ spooled= # for file in $*; do # spoolthis=TRUE ifn="`basename $file`" if [ -f $file ] then inputfile=$ifn mlogfile=${ifn}.rlog else inputfile=${file}.inp if [ -f $inputfile ] then mlogfile=${ifn}.rlog else echo Input files $file and $inputfile do not exist. spoolthis= fi fi # if [ $spoolthis ] then echo Input file: $inputfile # # Creating the spool file. # spoolhead="${spoolfilehead}_$ppid" spoolfile="${spooldir}/${spoolhead}.$ifn" # while [ -f $spoolfile ] do spoolhead="${spoolhead}x" spoolfile="${spooldir}/${spoolhead}.$ifn" done # echo "# Spool file created by script AiresTask. DO NOT EDIT." > $spoolfile echo "# User: ${LOGNAME}, date: `date`" >> $spoolfile echo "#" >> $spoolfile # echo "OriginalUser=$LOGNAME" >> $spoolfile echo "WorkingDirectory=`pwd`" >> $spoolfile echo "InputFile=$inputfile" >> $spoolfile echo Program=\"\$$progvar\" >> $spoolfile echo "Log0File=$mlogfile" >> $spoolfile echo "SpoolingDate=\"`date`\"" >> $spoolfile # echo "#" >> $spoolfile # echo Task normally spooled. echo "Log file (${mlogfile}) will be placed in current directory." echo # spooled=TRUE fi # done # # Firing up the processing program. # if [ "$spooled" = TRUE -a "$launch" = TRUE ] then ${Airesbindir}/AiresLaunch -i $spoolnumber fi # exit # # This script file is part of the AIRES Runner System; # AIRES 2.8.4a distribution. # # xxx 0 Tue Dec 12 16:28:05 ART 2006