#!/bin/ksh # # rlogin # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 2001 by Dan Harkless, and is released under the # GNU General Public License . # # DESCRIPTION: # Setups where mutliple machines NFS-mount your home directory are great # because you can seamlessly rlogin from machine to machine as needed, running # X applications and displaying them on your workstation. # # Well... it's not quite _that_ easy. Before you rlogin to the new machine # you have to xhost it (or xhost -, which is a bad idea). Once you're there, # you have to set the $DISPLAY environment variable to point to your X # workstation. This is a pain to do manually, so this script wraps around the # real rlogin executable and does these steps for you. # # If $DISPLAY is :0.0 (meaning this login session is on your local X # workstation), and you have not yet xhosted your destination machine, this # script does a simple "xhost $1". In the future, I may enhance it to do an # "xhost @" on OSes (such as Solaris) that support it. If you now # rlogin to a third machine from the second one, unfortunately an automatic # xhost cannot be done, since xhost only works on the console of the X # workstation you're using. # # To get $DISPLAY set properly, the script operates on the assumption that you # always have the variable set properly in your current environment before you # rlogin somewhere else. It writes the current setting to a file called # ~/.DISPLAY. If you have the line: # # if (! $?DISPLAY) setenv DISPLAY `cat ~/.DISPLAY` # # or its Bourne-shell-compatible equivalent in your .login, $DISPLAY will be # set up properly once you're rlogged in to your destination. # # As this script exits, it undoes any xhosting that it has done. # # Of course the real solution to the problem this script fixes is to use ssh # (with X11 forwarding) instead of rlogin, but if you don't have that # available on all your machines, you can use this as a poor man's version. # # DATE MODIFICATION # ========== ================================================================== # 2001-07-18 For some reason on Linux they use "unix:0.0" to mean ":0.0". # 1999-03-27 Look for rlogin in a series of locations rather than checking OS. # 1996-10-03 rlogin is in /usr/ucb instead of /usr/bin on SunOS 4.x. # 1996-07-31 Original. if [ "$DISPLAY" = ":0.0" -o "$DISPLAY" = "unix:0.0" ]; then if [ `xhost | fgrep -c $1` = 0 ]; then trap 'xhost -$1' 0 1 2 3 15 xhost $1 fi echo $HOST:0.0 > ~/.DISPLAY else echo "$DISPLAY" > ~/.DISPLAY fi rlogin="" rlogin_locations="/usr/bin /usr/ucb" # anywhere else? for dir in $rlogin_locations; do if [ -x $dir/rlogin ]; then rlogin=$dir/rlogin fi done if [ "$rlogin" = "" ]; then echo $0": rlogin not found in ($rlogin_locations)." exit 1 else $rlogin "$@" -8 # 7-bit pipe is a really stupid default for rlogin... fi