| 1 |
#!/bin/csh -f |
| 2 |
# note for cygwin: |
| 3 |
# csh is not standard in the distribution. |
| 4 |
# tcsh can be downloaded though, and put in /bin, |
| 5 |
# and then link /bin/csh to it. |
| 6 |
# same for linking /bin/awk --> /bin/gawk |
| 7 |
# gv is prefered to ghostview, search www.google.com. |
| 8 |
### viewanddel is distributed with "Doris". |
| 9 |
### used with scripts plotoffsets and plotcpm |
| 10 |
### Bert Kampes, (c) 1998-2004 |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
### Check input |
| 15 |
set PSFILE = $1 |
| 16 |
set WRONG = 0; |
| 17 |
if ( $#argv != 1 ) set WRONG = 1 |
| 18 |
if ( ! -e "$PSFILE" ) set WRONG = 1 |
| 19 |
if ( $WRONG == 1 ) then |
| 20 |
echo "$0 file.ps" |
| 21 |
echo "View a temporary postscript file and" |
| 22 |
echo "then delete it afterwards." |
| 23 |
echo " " |
| 24 |
exit 1 |
| 25 |
endif |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
### Decreasing order of desiredness... |
| 30 |
### First try to get gv, then ghostview, |
| 31 |
### if not found, assume a program named "ghostview" |
| 32 |
### exists. Do not use "which" command here. |
| 33 |
#%// BK 25-Sep-2001 which seems more robust than -x... |
| 34 |
#%// BK 16-Jun-2003 but which is extremely slow on SUN... |
| 35 |
#%// BK 16-Jun-2003 therefore simply use "ghostview" and assumes |
| 36 |
#%// BK 16-Jun-2003 everybody has that, or is smart enough to change it here |
| 37 |
### If you want to use a different program, |
| 38 |
### simply make sure it is known as "ghostview" using a link. |
| 39 |
### or put it under that name in ~/bin/ghostview |
| 40 |
set PSVIEWERS = "gv ghostview gsview32" |
| 41 |
set BINDIRS = "/usr/X11R6/bin /bin /usr/bin /usr/local/bin /usr/sbin ~/bin ~/local/bin" |
| 42 |
set GV = ghostview |
| 43 |
foreach PSVIEWER ( $PSVIEWERS ) |
| 44 |
foreach BINDIR ( $BINDIRS ) |
| 45 |
if ( -x $BINDIR/$PSVIEWER ) then |
| 46 |
set GV = $BINDIR/$PSVIEWER |
| 47 |
break |
| 48 |
endif |
| 49 |
end |
| 50 |
end |
| 51 |
echo $GV |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
### set PSVIEWER = "/cygdrive/c/Program Files/gs3/Ghostgum/gsview/gsview32" |
| 56 |
### cygwin: do not use a space in path to executable. |
| 57 |
### cygwin: prepend X11R6/bin so correct gs is used |
| 58 |
### to avoid "postscript interpreter failed in main window" error. |
| 59 |
### Note also GS_LIB GS_FONTPATH may be set, but does not |
| 60 |
### seem important (see gs -h). |
| 61 |
if ( -d /cygdrive ) then |
| 62 |
echo "Cygwin detected: prepending /usr/X11R6/bin to path" |
| 63 |
set path = ( /usr/X11R6/bin $path ) |
| 64 |
endif |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
### Add options to viewer. |
| 69 |
### Finally call postscript viewer |
| 70 |
echo "Using $GV" |
| 71 |
$GV -fg black -bg white $PSFILE |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
### Remove postscript file if viewing was OK. |
| 76 |
if ( $status == 0 ) then |
| 77 |
echo "removing tmp postscript file $PSFILE" |
| 78 |
rm -f $PSFILE |
| 79 |
else |
| 80 |
echo "Something went wrong with viewer. Please have a look" |
| 81 |
echo "at postscript file $PSFILE yourself." |
| 82 |
echo "E.g., try following command from promt:" |
| 83 |
echo " $GV $PSFILE" |
| 84 |
echo " " |
| 85 |
exit 1 |
| 86 |
endif |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
### EOF |
| 91 |
exit 0 |
| 92 |
|