#!/bin/csh
# xremote - This script runs X11 applications on
# a Sun Unix server and sets the DISPLAY to a
# remote workstation.
#-------------------------------------------------------------
# INSTALLATION:
# 1. Create a world-readable file in your CCU home directory
# called .rhosts. .rhosts should contain, for each 
# workstation on which you plan to run programs remotely, 
# a line of the form 
#
# host userid
#
# where host is the workstation and userid is your userid on 
# that workstation eg.
#
# mendel.plants.umanitoba.ca gregor
#
# Similarly, your home directory on the remote workstation
# should contain a .rhosts file with the hosts and userids
# that should be allowed to remotely run jobs on that
# workstation. eg. mira.cc.umanitoba.ca gregor
#
# So, what the .rhosts files do is give particular users
# from specific hosts permission to run jobs as a particular
# user on another host.
#
# 2. Put xremote into your $home/bin directory. Make sure
# the execute permission is set.
# 
# 3. To run xremote from a workstation, open a shell window
# and login to one of the CCU servers specified in your
# .rhosts file. Next type 'xremote' and you will be
# prompted for commands to run remotely. Type 'quit'
# when you want to quit.

#-------------------------------------------------------
# Change this line to the host where you want the
# display to appear
setenv DISPLAY 'pssun1.plants.umanitoba.ca:0'

# This line adds the xview libraries to your path
#on the SUN. 
set path = ($path /usr/openwin/bin/xview) 

# Change this line to the host where you want the
# display to appear
rsh -l frist pssun1.plants xauth extract - $DISPLAY | xauth merge - 

# The script will keep prompting for commands
# In the current implementation, it will only 
# execute single word commands, that is, the 
# script will take the first non-blank string
# on the line, and run that. So
#
# gde
#
# would start gde with no files read, but
# the same result would be obtained by typing
#
# gde junk.gde
# 
# The latter, if typed at the Unix prompt, 
# would start gde and open the file junk.gde
# xremote isn't smart enough to do that.
# One of these days I'll make it read a whole line.
echo 'Enter a command to run on remote host, or "quit":'
set COMMAND = $<

while ($COMMAND != "quit")
  if ($COMMAND != "xremote") then
      csh -c $COMMAND &
      endif
  echo 'Enter a command to run on remote host, or "quit":'
  set COMMAND = $<
  end