#! /bin/csh -f
# Last modified on Fri Sep 21 14:31:03 PDT 1990 by stolfi 
#==================================================
# Usage: spool-ps-file
#   [-printer <printer>] [-host <spooling host>] <postscript file>
# Ships postscript file to spooling machine, and 
#   runs lpr [-P<printer>] -s there.
#==================================================

set printerop = "-P$PRINTER"
set host = ""
set copiesop = ""
while ( $#argv > 1 )
  if ( "X$1" == "X-printer" ) then
    set printerop = "-P"$2
    shift; shift
  else if ( "X$1" == "X-host" ) then
    set host = $2
    shift; shift
  else
    break
  endif
end

if ( $#argv < 1  ) then
  echo "Missing argument"
  exit(1)
endif

foreach f ( $* )
  set f = $f:r
  if ( ( "X$host" == "X" ) || ( "X$host" == "X$MACHINE" ) ) then
    nice lpr $printerop -s $f.ps
  else
    echo shipping $f.ps to $host... &&\
    copy $f.ps /$host/tmp/$$-$f.ps &&\
    msh $host "nice lpr $printerop -s /tmp/$$-$f.ps"
  endif
end

# END


