Annotation of 43BSDTahoe/new/dipress/ucblpr/ascf.op, revision 1.1.1.1

1.1       root        1: #! /bin/csh -f
                      2: #  NOTE:  USING C SHELL, not bourne shell.
                      3: # Filter for straight ascii text
                      4: # arguments:
                      5: # ascf -w90 -l160 -i0 -n <user> -h <Proc.Host> -J<filename> -C<subm.Host> 
                      6: #      -D<Other parms> -D<more parms>
                      7: echo $* >> /tmp/kk$$
                      8: 
                      9: umask 077
                     10: set TMP=/tmp/maha$$ ERR=/tmp/mahaE$$ noglob
                     11: onintr cleanup
                     12: 
                     13: # Figure out which printer:
                     14: switch ( $0 )
                     15: case *.dp :
                     16:        set PTR=diderot
                     17:        set STAT=/usr/spool/dpd/status
                     18:        set ACCT=/usr/adm/dpacct
                     19: breaksw
                     20: case *.op :
                     21:        set PTR=darwin
                     22:        set STAT=/usr/spool/opd/status
                     23:        set ACCT=/usr/adm/opacct
                     24: breaksw
                     25: endsw
                     26: 
                     27: echo "Formatting job." > $STAT
                     28: chmod a+r $STAT
                     29: 
                     30: #Set defaults, then Parse the parameters:
                     31: set UPARM=
                     32: set FNAME=stdin
                     33: 
                     34: while ( $#argv > 0 )
                     35:   switch ( "$argv[1]" )
                     36:     case -D* :                 # -D<uparms>    from lpr -D option
                     37:        set T=(`echo $argv[1] | sed -e 's/^-D//'`)
                     38:        set UPARM=($UPARM $T)
                     39:     breaksw
                     40:     case -J* :                 # -J<filename>  lpd supplies or from lpr -J opt
                     41:        set FNAME=(`echo $argv[1] | sed -e 's/^-J//'`)
                     42:     breaksw
                     43:     case -h :                  # -h <host>     lpd supplies
                     44:        shift argv
                     45:        set HOST=(`echo $argv[1] | sed -e 's/.berkeley.edu//'`)
                     46:     breaksw
                     47:     case -n :                  # -n <user>     lpd supplies
                     48:        shift argv
                     49:        set USER=$argv[1]
                     50:     breaksw
                     51:     default:
                     52:     breaksw
                     53:   endsw
                     54:   shift argv
                     55: end
                     56: 
                     57: # Now get ready to scan any user-specified arguments.  Mainly we must sort
                     58: # out which goto maha and which to xnsprint.  The proper quotation for passing
                     59: # arguments looks something like this:
                     60: #      lpr -Puxp -D'-c2 -h "This is a heading" -b "A Banner" -R'
                     61: 
                     62: eval set argv = \( $UPARM \)
                     63: unset BANNER UNAME UPARM
                     64: set COPYS="1" UPARM
                     65: 
                     66: while ( $#argv > 0 )
                     67:   switch ( "$argv[1]" )
                     68:     case -P:                   # -P <printer>  (Invalid!  Eat it.)
                     69:        if ( $#argv > 1) shift argv
                     70:     case -P*:                  # -P<printer>   (Invalid!  Eat it.)
                     71:     breaksw
                     72:     case -c:                   # -c <copies>   (Pass to xnsprint)
                     73:        if ( $#argv > 1) shift argv
                     74:        set COPYS = ($argv[1])
                     75:     breaksw
                     76:     case -c*:                  # -c<copies>    (Pass to xnsprint)
                     77:        set COPYS=(`echo $argv[1] | sed -e 's/^-c//'`)
                     78:     breaksw
                     79:     case -b:                   # -b <banner>   (pass to xnsprint)
                     80:        if ( $#argv > 1) shift argv
                     81:        set BANNER = ($argv[1])
                     82:     breaksw
                     83:     case -b*:                  # -b<banner>    (Pass to xnsprint)
                     84:        set BANNER =(`echo $argv[1] | sed -e 's/^-b//'`)
                     85:     breaksw
                     86:     case -n:                   # -n <name>     (pass to xnsprint)
                     87:        if ( $#argv > 1) shift argv
                     88:        set UNAME = ($argv[1])
                     89:     breaksw
                     90:     case -n*:                  # -n<name>      (Pass to xnsprint)
                     91:        set UNAME =(`echo $argv[1] | sed -e 's/^-n//'`)
                     92:     breaksw
                     93:   default:
                     94: # quote each argument to keep 'em from coming unglued.
                     95:        set UPARM = ( $UPARM \"$argv[1]\" )
                     96:   endsw
                     97:   shift argv
                     98: end
                     99: 
                    100: set NAME=${USER}@${HOST}
                    101: 
                    102: # Supply some defaults incase the user didn't.
                    103: if ( ! $?UNAME) set UNAME = $NAME
                    104: if ( ! $?BANNER) set BANNER = $FNAME
                    105: #umask 002
                    106: 
                    107: # Pass user arguments in the environment.  maha will pair up quotes.
                    108: # (Otherwise would have to 'eval' maha cmd to get the csh to parse quotes.)
                    109: setenv MAHA "-h$FNAME -2 -r -t -fterminal/8 $UPARM"
                    110: 
                    111: /usr/local/maha -o $TMP >& $ERR
                    112: 
                    113: goto retry
                    114: retry:
                    115: if ( -e $TMP ) then
                    116:     eval /usr/new/xnsprint -P $PTR -a$STAT -c \"$COPYS\" -n \"$UNAME\" -b \"$BANNER\" -q $TMP 
                    117:     switch ($status)
                    118:     case 132:
                    119:            echo xnsprint lost courier connection
                    120:            goto retry
                    121:     case 1:
                    122:     case 2:
                    123:     case 3:
                    124:            echo Encountered network problems, trying again. > $STAT
                    125:            goto retry
                    126:     endsw
                    127:     /usr/local/lib/ipcount -d -n $USER -h $HOST $ACCT < $TMP
                    128: else
                    129:   echo "daemon: Can't find maha output; Skipping xnsprint" >> $ERR
                    130: endif
                    131: 
                    132: if ( ! -z $ERR ) then
                    133:   /usr/ucb/Mail -s "Maha Error Output" $NAME < $ERR
                    134: endif
                    135: 
                    136: rm -f $TMP $ERR
                    137: exit 0
                    138: 
                    139: cleanup:
                    140: rm -f $TMP $ERR
                    141: exit 1

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.