Debian Codegraph @

src/bin/geomutil/maple2oogl/remotegv

raw
1 #! /bin/sh
2
3 # Invoke geomview possibly remotely.
4 # For use within Maple, install this remotegv script somewhere in users'
5 # search paths (e.g. in /usr/local/bin).
6 # This script attempts to guess which machine to invoke geomview on by
7 # examining the DISPLAY environment variable. If DISPLAY isn't set or
8 # if geomview should run on a different machine, use the -h host option.
9 #
10 # The script also assumes that geomview should display on the machine where
11 # it is invoked, so for that copy of geomview, it sets DISPLAY to ":0".
12 # If the display should appear elsewhere (on an X terminal, say),
13 # use the -display option.
14 #
15 # We use "rsh" (remote shell) to pass data to the other computer, so
16 # the remote computer must allow this -- either with an entry in
17 # /etc/hosts.equiv, or in a .rhosts file in the user's home directory
18 # on the machine where geomview will run. The account name on the other
19 # machine is assumed to be the same as on this machine; if different,
20 # use the -l username or -h username@othermachine options.
21 #
22 # In case permissions are not set up correctly, the symptom
23 # is liable to be a "Permission denied." message followed by the
24 # immediate termination of the Maple process -- so if you're using it for
25 # the first time, check it out before doing much else in your Maple session!
26 # Sorry, but MapleV3 is just not very good at connecting to other programs.
27 #
28 # Note that togeomview and geomview MUST BE IN THE USER'S DEFAULT SEARCH PATH
29 # on the remote machine.
30 #
31 # To use this script within Maple, you'd say:
32 # readlib(gvplot);
33 # then
34 # gvcommand := `remotegv`;
35 # or e.g.
36 # gvcommand := `remotegv -h othermachine -display myxterm:0`;
37 # or, if the account on the other machine is different from yours,
38 # gvcommand := `remotegv -l otheraccount`;
39 # or
40 # gvcommand := `remotegv -h otheraccount@othermachine`;
41 # Following any remotegv options, you can add the command to be invoked as
42 # geomview, possibly including options, as in:
43 # gvcommand := `remotegv -l person /u/person/bin/gv -wpos 300x200`;
44 #
45 # Then use gvplot() as usual.
46 #
47 # Normally, error messages reporting problems on the other machine (for
48 # example, being unable to run geomview) are suppressed; this is unfortunately
49 # necessary, or you'd never get another Maple prompt until quitting from
50 # geomview. There's a test mode to aid in tracing problems; use it as in
51 # gvcommand := `remotegv -test -h othermachine`;
52 # i.e. add "-test" to whatever other options you'd give to remotegv.
53 #
54 # Option summary:
55 # -l user or -l user@host
56 # -h host or -h user@host
57 # -display host:number (set display on remote end)
58 # -test
59 # also accepts togeomview's options (-g, -M[c][g][p][s]).
60
61 # Invokes rsh to specified machine, invokes togeomview there by default.
62 #
63 # By default, we assume DISPLAY points to the machine where we'd like to be;
64 # -h {host-portion-of-DISPLAY} -display :0
65 # Incorporates settings from "$RGVOPTS" environment variable.
66
67 set -- $RGVOPTS "$@"
68 set -x
69 RGVSH=${RGVSH:-rsh}
70
71 while
72 case "$1" in
73 -l)
74 case "$2" in
75 *@*) user="`expr match "$2" '\([^@]*\)'`"
76 host="`expr match "$2" '.*@\(.*\)'`" ;;
77 *) user="$2" ;;
78 esac
79 shift 2 ;;
80
81 -h) case "$2" in
82 *@*) user="`expr match "$2" '\([^@]*\)'`"
83 host="`expr match "$2" '.*@\(.*\)'`" ;;
84 *) host="$2" ;;
85 esac
86 shift 2 ;;
87
88 -test) testopt=-test; shift ;;
89 -display) rdisplay="$2"; shift 2 ;;
90 -M*) togvopts="$togvopts $1";
91 inpipe="$2"
92 shift 2 ;;
93 -g) gopt=-g; shift ;;
94 "") test ;;
95 *) togvargs="$togvargs $1"; shift ;;
96 esac
97 do :
98 done
99
100 # Apply defaults
101
102 if [ -z "$host" ]; then
103 host="`expr match "$DISPLAY" '\([^:]*\)'`"
104 fi
105
106 if [ -z "$rdisplay" ]; then
107 rdisplay=":0.0"
108 fi
109
110 case "$inpipe" in
111 /*) ;;
112 ?*) inpipe=/tmp/geomview/$inpipe ;;
113 esac
114
115 user=${user+"-l $user"}
116 cmd="${host+$RGVSH $host $user}"
117
118 if [ -n "$host" ]; then
119 redirect=">/dev/null 2>&1"
120 if [ -n "$testopt" ]; then
121 echo "Testing setup to $host. If geomview or togeomview can't be started
122 there, you should see messages explaining why. Unfortunately this command
123 may not finish on its own -- you may need to interrupt (perhaps with control-C)
124 after seeing the results, before you get another Maple prompt." >&2
125 redirect=""
126 fi
127 if [ -n "$inpipe" ]; then
128 $RGVSH $host $user sh -c "\"DISPLAY=$rdisplay togeomview $gopt ${togvopts} $inpipe $togvargs $redirect\"" <$inpipe
129 else
130 $RGVSH $host $user sh -c "\"DISPLAY=$rdisplay togeomview $gopt ${togvopts} $togvargs $redirect\""
131 fi
132 else
133 case "$1" in
134 ""|-*) DISPLAY=$rdisplay geomview ${togvopts} $togvargs ;;
135 *) DISPLAY=$rdisplay ${togvopts} $togvargs;;
136 esac
137 fi