Skip to content
Snippets Groups Projects
run_sigcleave 1.51 KiB
Newer Older
tjc's avatar
tjc committed
#!/bin/sh -

# this script will run a search program on a sequence input file or on each
# file in a file of filenames

# to customise this script see the function called run_one_prog below


tjc's avatar
tjc committed


if [ $# = 4 -a x$1 = x-onefile ]
then
    shift
    ONEFILE=t
    MINWEIGHT=$3
else
    if [ $# = 2 ]
    then
        MINWEIGHT=$2
    else
        echo usage: $0 -onefile input_file output_file minimum_weight 1>&2
        echo    or: $0 file_of_filenames minimum_weight 1>&2
        exit 1
    fi
fi

PARAMETERS="-minweight $MINWEIGHT"

### change this function to suit your site:

run_one_prog () {
    INPUT_FILE=$1
    OUTPUT_FILE=$2
    PARAMETERS="$3 $4 $5 $6 $7 $8 $9"

    ### change these lines:
    EXEC=sigcleave

    COMMAND="$EXEC $INPUT_FILE -outfile $OUTPUT_FILE $PARAMETERS"
tjc's avatar
tjc committed

    echo
	echo "input file: $INPUT_FILE"
	echo "output will be written to: $OUTPUT_FILE"
	echo "executing command: $COMMAND" 1>&2
tjc's avatar
tjc committed

    # add/change the flags to suit your site:
    $COMMAND 2>&1 | tee ${PROG}_errors.new 1>&2
tjc's avatar
tjc committed

    #### end of changes


    if [ -s ${PROG}_errors.new ]
    then
        ( echo ERROR running $PROG: ; echo; 
          echo ===================================================
          cat ${PROG}_errors.new ) >> $OUTPUT_FILE
        cat ${PROG}_errors.new >> ${PROG}_errors
    fi
}

(echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill

chmod a+x $PROG.kill

if [ x$ONEFILE = x ]
then
    for i in `cat $1`
    do
        run_one_prog $i $i.out $PARAMETERS
    done

else
    run_one_prog $1 $2 $PARAMETERS
fi

exit 0