#!/bin/sh #******************************************************************** # OK, the end-all axis + xplot + print script # now even PostScript transferrer. Works for "term" SL/IP like conn # Copyright (c) 1993 Karl J. Runge, Sep 24 VERSION="xaxa v0.3 Copyright (c) 1993 Karl J. Runge" #******************************************************************** #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # change this to "on" in Brentwood (term) # "" elsewhere #WE_ARE_HOME="" # or use this test: #if [ "`hostname | grep haystack`" = "" ]; then # WE_ARE_HOME="" #else # WE_ARE_HOME="True" #fi WE_ARE_HOME="True" #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Prg="`basename $0`"; # start with misc: #TERMHOST="bach.llnl.gov" TERMHOST="jfku.edu" ARGS="$*" # shell script switches: ERROR="" THREE_D="" REMOVE_SRC="" SOURCE_IS_AXIS_OUT="" SOURCE_IS_PS="" SPLIT="" STDIN="" GO_HOME="" PRINT="" SPOOLPS="" SPOOLAXIS="" WAIT="" WIDTH="" SHIFT="" # commands(more or less): CAT="cat" AXIS="axis -w 0.85 -r 0.05" GS="gs" GV="ghostview" GV_GEOM="-geometry +0+0" XPLOT_HOME="xplot"; #XGRAPH="| egrep -v 'a|T' | sed -e 's/#//' | xgraph" #XGRAPH="sed -e 's/^ *[A-z].*/\"&\"/' | sed -e 's/^ *#.*/ /' | xgraph" XGRAPH="sed -e 's/#/\"a/' | xgraph" if [ "X$XGRAPH_LW" != "X" ]; then XGRAPH="$XGRAPH -lw $XGRAPH_LW" fi LPR="lpr"; PRINT_HOME="lpr"; SPLITTER="xasp"; LASERARGS=" -f -R -t8 " SPOOLCMD="laser3 "$LASERARGS if [ "$WE_ARE_HOME" = "" ]; then XPLOT="Xplot" XPLOT="$XPLOT_HOME" # for network PRINTCMD=" $LPR" elif [ "$WE_ARE_HOME" = "True" ]; then XPLOT="$XPLOT_HOME" PRINTCMD=" $PRINT_HOME" fi # command options: COLOR=" -fg white -bg cadetblue " GEOM=" -geometry 550x550" GEOM_ADD=""; GEOM_ADD=`ran_geom 2>/dev/null`; # files: SRC="" TMPFILE=/tmp/xax_all$$ TMPSTDIN=/tmp/xax_stdin$$ # Process Environmentals: if [ "$MONO" = "YES" ]; then # COLOR="" COLOR=" -fg black -bg white " fi # Define clean clean () { if [ "$REMOVE_SRC" = "True" ]; then rm $SRC fi rm -f $TMPFILE rm -f $TMPSTDIN } # Define help: help () { echo "" echo "Usage: $Prg [] " echo "" echo "Where can be:" echo "" echo "-3 [3D plot]" echo "-e [plot error bars]" echo "-h [ship source to Brentwood and axis/xplot/print there]" echo "-help [print what you're looking at now]" echo "-R [remove sourcefile upon completion]" echo "-v [display version information]" echo "-z [sourcefile is gnu-zipped (gzip)]" echo "-wait [do not go into background]" echo "-w n [add width fraction to axis input]" echo "-r n [add do horizontal shift fraction to axis input]" echo "-W [-w and -r of 0.8 and 0.06]" echo "-P [pipe PostScript from laser3 to printer(somehow)]" echo " [can be -Pprinter, but not -P printer]" echo "-x send to xgraph" echo "-ps [spool PostScript from laser3 to stdout]" echo "-sps [source IS PostScript, view with GhostScript or print]" echo "-a [spool axis output plot5 commands]" echo "-sa [source is actually axis output(i.e. plot5 cmds]" echo "-S [filter through \"splitter\" script xasp first]" echo "-geom [specify geometry]" echo "-g use geom +0+0" echo "" echo " [Axis/xplot commands and data. One file only]" echo "" } # Process args: while [ "$1" != "" ] do case $1 in "-3") THREE_D="True" ;; "-3args") shift; THREE_D_ARGS="$1" ;; "-e") ERROR="True" ;; "-w") shift; WIDTH="# w $1" ;; "-r") shift; SHIFT="# r $1" ;; "-W") WIDTH="# w 0.80" SHIFT="# r 0.06" ;; "-wait") WAIT="-N" ;; "-h") GO_HOME="True" ;; "-help") help; exit ;; "-q") help; exit ;; "-R") REMOVE_SRC="True" ;; "-v") echo $VERSION; exit 0 ;; "-z") CAT="gzip -dc" ;; "-ps") SPOOLPS="True" ;; "-sps") SOURCE_IS_PS="True" ;; "-a") SPOOLAXIS="True" ;; "-sa") SOURCE_IS_AXIS_OUT="True" ;; "-sq") AXIS="axis -w 0.95 -h 1.0" ;; "-g") GEOM_ADD="+0+0"; ;; "-geom"*) shift; GEOM_ADD="$1"; ;; "-P"*) PRINT="True" if [ "X$1" != "X-P" ]; then PRINTCMD="$PRINTCMD $1"; fi ;; "-lw") XGRAPH="$XGRAPH $1 $2"; shift ;; "-x") shift; # set -xv eval "cat $* | $XGRAPH" exit 0 ;; "-S") SPLIT="True" ;; "-") STDIN="True" ;; "-"*) echo; echo "$Prg: $1 not an option"; help; exit 1 ;; *) if [ "$SRC" = "" ]; then SRC="$1" else echo "" echo "$Prg: $1: Only one filename please!" echo "$Prg: Using file \"$SRC\", sorry." fi ;; esac shift done if [ "`echo $GEOM_ADD | grep x`" = "" ]; then GEOM="${GEOM}$GEOM_ADD"; else GEOM="-geometry $GEOM_ADD"; fi if [ "$GO_HOME" = "True" ] && [ "$SRC" = "" ] && [ "$STDIN" = "" ]; then help; exit 0; fi if [ "$STDIN" = "True" ]; then if [ "$SRC" = "" ]; then cat > $TMPSTDIN; SRC="$TMPSTDIN"; fi fi # If doing at home just ship it and exit if [ "$GO_HOME" = "True" ] && [ "$WE_ARE_HOME" = "" ] && [ "$THREE_D" = "" ]; then hayput -ct $SRC $TMPFILE # do following kludge on filename (i.e., 2 sourcefile names sent!) # should strip out "$SRC", use either sed or awk...anything better? # also, this doesn't work in background...ugh rsh $TERMHOST trsh -s \"xaxa $TMPFILE -R $ARGS\" # do cleanup here so we can just exit... clean exit 0 fi # Make basic command: #XPLOT="$XPLOT $WAIT $GEOM $COLOR" XPLOT="$XPLOT $GEOM $COLOR" # 3D changes, kludge for now if [ "$THREE_D" = "True" ]; then if [ "$THREE_D_ARGS" != "" ]; then export THREE_D_ARGS fi AXIS="plt3" XPLOT="echo" fi # Is source is already processed by axis... if [ "$SOURCE_IS_AXIS_OUT" = "True" ]; then AXIS="cat" fi # Is source is already PostScript... if [ "$SOURCE_IS_PS" = "True" ]; then AXIS="cat > /dev/null" if [ "$PRINT" = "True" ]; then XPLOT="$PRINTCMD" else TEST=`type $GV 2>&1 | grep 'not found'` if [ "$TEST" = "" ]; then XPLOT="$GV $GV_GEOM $TMPFILE" else XPLOT="$GS $TMPFILE" fi fi elif [ "$PRINT" = "True" ]; then XPLOT="$SPOOLCMD | $PRINTCMD" fi if [ "$SPOOLPS" = "True" ]; then XPLOT="$SPOOLCMD" elif [ "$SPOOLAXIS" = "True" ]; then XPLOT="cat" fi # Make file to actually process: if [ "$SPLIT" = "" ]; then $CAT $SRC > $TMPFILE else $CAT $SRC | $SPLITTER > $TMPFILE fi if [ "$ERROR" = "True" ]; then echo " # e " >> $TMPFILE $CAT $SRC >> $TMPFILE fi # Go do it: if [ "X$WIDTH$SHIFT" != "X" ]; then echo "$WIDTH" > $TMPFILE.tmp echo "$SHIFT" >> $TMPFILE.tmp cat $TMPFILE >> $TMPFILE.tmp mv $TMPFILE.tmp $TMPFILE fi eval "cat $TMPFILE | $AXIS | $XPLOT" #DBUG echo "cat $TMPFILE | $AXIS | $XPLOT" if [ "X$WAIT" != "X" ]; then pid=`ps waux | grep -i xplot | grep -v grep | awk '{print $2}' | head -1` Pwait $pid fi clean exit 0;