1#!/bin/sh -
2
3# this script will run a search program on a sequence input file or on each
4# file in a file of filenames
5
6# to customise this script see the function called run_one_prog below
7
8
9RCS_HEADER="$Header: //tmp/pathsoft/artemis/etc/run_sigcleave,v 1.1 2004-06-09 10:03:11 tjc Exp $"
10
11PROG=`echo $RCS_HEADER | sed 's/.*run_\(.*\),v.*/\1/'`
12
13
14if [ $# = 4 -a x$1 = x-onefile ]
15then
16    shift
17    ONEFILE=t
18    MINWEIGHT=$3
19else
20    if [ $# = 2 ]
21    then
22        MINWEIGHT=$2
23    else
24        echo usage: $0 -onefile input_file output_file minimum_weight 1>&2
25        echo    or: $0 file_of_filenames minimum_weight 1>&2
26        exit 1
27    fi
28fi
29
30PARAMETERS="-minweight $MINWEIGHT"
31
32### change this function to suit your site:
33
34run_one_prog () {
35    INPUT_FILE=$1
36    OUTPUT_FILE=$2
37    PARAMETERS="$3 $4 $5 $6 $7 $8 $9"
38
39    ### change these lines:
40    EXEC=sigcleave
41
42    COMMAND_LINE="$EXEC $INPUT_FILE -outfile $OUTPUT_FILE $PARAMETERS"
43
44    echo "about to start $EXEC with input from $INPUT_FILE and output to" 1>&2
45    echo "$OUTPUT_FILE using parameters: $PARAMETERS" 1>&2
46    echo "command line: $COMMAND_LINE" 1>&2
47
48    # add/change the flags to suit your site:
49    $COMMAND_LINE 2>&1 | tee ${PROG}_errors.new 1>&2
50
51    #### end of changes
52
53
54    if [ -s ${PROG}_errors.new ]
55    then
56        ( echo ERROR running $PROG: ; echo;
57          echo ===================================================
58          cat ${PROG}_errors.new ) >> $OUTPUT_FILE
59        cat ${PROG}_errors.new >> ${PROG}_errors
60    fi
61}
62
63(echo "#!/bin/sh -"; echo "kill $$") > $PROG.kill
64
65chmod a+x $PROG.kill
66
67if [ x$ONEFILE = x ]
68then
69    for i in `cat $1`
70    do
71        run_one_prog $i $i.out $PARAMETERS
72    done
73
74else
75    run_one_prog $1 $2 $PARAMETERS
76fi
77
78exit 0
79