SUMMARY: OpenWindows Across Machines

From: Sun Managers at Telecom (sunman@telecom.telecom.com)
Date: Sat Oct 08 1994 - 04:18:56 CDT


Many Thanks to all who replied.

As was pointed out by a couple of people, I _WAS_ swamped by answers.

There were many helpfull answers, two that were wrong (but that is
OK), 1 that asked that I forward the solution. There was one flame and
2 simi-flames. But even they included an answer.

Original Problem Statement:
>I have some Openwindows programs on a machine (x), and I want to run them
>on another (y). When I rsh to x from y, and then try to run the program, I
>get:
>
>XView error: Cannot open connection to window server: :0 (Server package)
> ^- What the heck is a window server??
>Or if I try to run filemgr I get:
>
>XView Error (Intercepted)
>Error: Cannot open connection to window server: :0
>Package: Server
>Non-Recoverable Error:
>dumping core file in /where/ever
>Abort
>
>What do I need to set or what application needs to be running to get this to
>work?
>

Solution:
Login to machine Y and after Openwindows is running, execute "xhost +".
There are no man pages on xhost, but there is an xman page on it. After
xhost is running, login to machine X and then set the display variable,

Bourne shell or Korn shell (sh or ksh):
        DISPLAY=y:0.0 export DISPLAY
C-shell (csh):
        setenv DISPLAY y:0.0

After doing this, all Openwindows apps that are on X seem to work fine and
display on Y.

If you logout of machine X, the next time you login, you have to re-set
the DISPLAY variable.

Another way was suggested by Lenny Turetsky.

"From the command line:
        program-foo -d host_I'm_really_on:0.0

The `-d' tells it to use the next argument as the name of the machine on
which to display. The 0.0 tells it which screen to display on.

Some programs demand the use of the `-display' rather than `-d' -- check
with the manpages."

There are no man pages for filemgr, but a trial finds that it requires the
-display instead of the -d. There are xman pages, but they don't say
anything about starting it on a remote machine.

Judi Connelly sent:
"...you need to set the DISPLAY as follows in your.openwin-init

#!/bin/sh
# .openwin-init - OpenWindows initialization script.
# WARNING: This file is automatically generated.
# Any changes you make here will be lost!
export DISPLAY

# Test for pathological case -- no $DISPLAY set
if [ "${DISPLAY}" = "" ]; then
        DISPLAY=:0
fi

# Figure out the proper host/server number
BASE=`echo $DISPLAY | sed -e 's/:.*//'`
DISPLAYNO=`echo $DISPLAY | sed -e 's/.*://' -e 's/\..*//'`
BASEDISPLAY=${BASE}:${DISPLAYNO}

SETDISPLAYSCREEN() {
        DISPLAY=${BASEDISPLAY}.$1
        if winsysck x11 ; then
                :
        else
                echo No display available for screen $1
                exit 1
        fi
}
# Note: toolwait is a utility to control client startup.
# For more information, see the toolwait(1) man page.
#
# Start clients on screen 0
#
SETDISPLAYSCREEN 0
#
toolwait clock -Wp 994 2 -Ws 145 84 -WP 393 833 -Wi +Wn -r -12 -digital +date -seconds -alarmtime 0:0
toolwait cmdtool -Wp 0 0 -Ws 590 77 -WP 3 833 +Wi -C
toolwait cmdtool -Wp 543 0 -Ws 593 870 -WP 237 833 +Wi
toolwait cmdtool -Wp 8 108 -Ws 521 305 -WP 471 833 +Wi
toolwait cmdtool -Wp 9 416 -Ws 493 363 -WP 549 833 +Wi
toolwait filemgr -Wp 0 120 -Ws 590 300 -WP 0 0 +Wi -r -i 5
toolwait mailtool -Wp 60 60 -Ws 585 281 -WP 315 833 -Wi
"

There were some script files that were sent, to help automate the process
a little.

Pat Max sent the following:
"...to make it easier I will send you the xon script which came
with X11r4 and the one that came with X11r5. The way you run them is
to type

xon machine command

or

xon machine xterm

and then in the xterm window, type the command. It will run on the
machine and display on yours. When I ran OW a number of years
ago, before I was converted to X11, I used to run the mailtool on
the server that had the mail that way."

Put it in /usr/local/bin and make it 755. I call this on xonr5 and the
other one xon.
X11r5 xonr5
#!/bin/sh
# start up xterm (or any other X command) on the specified host
# Usage: xon host [arguments] [command]
case $# in
0)
        echo "Usage: $0 <hostname> [-user user] [-name window-name] [-debug]"
        echo "[-screen screen-number] [command ...]"
        exit 1
        ;;
esac
target=$1
shift
label=$target
resource=xterm-$label
rcmd="rsh $target"
case $DISPLAY in
unix:*)
        DISPLAY=`echo $DISPLAY | sed 's/unix//'`
        ;;
esac
case $DISPLAY in
:*)
        fullname=`hostname`
        hostname=`echo $fullname | sed 's/\..*$//'`
        if [ $hostname = $target -o $fullname = $target ]; then
                DISPLAY=$DISPLAY
                rcmd="sh -c"
        else
                DISPLAY=$fullname$DISPLAY
        fi
        ;;
esac
username=
xauth=
case x$XUSERFILESEARCHPATH in
x)
        xpath='HOME=${HOME-`pwd`} '
        ;;
*)
        xpath='HOME=${HOME-`pwd`} XUSERFILESEARCHPATH=${XUSERFILESEARCHPATH-"'"$XUSERFILESEARCHPATH"'"} '
        ;;
esac
redirect=" < /dev/null > /dev/null 2>&1 &"
command=
ls=-ls
continue=:
while $continue; do
        case $1 in
        -user)
                shift
                username="-l $1"
                label="$target $1"
                rcmd="rsh $target $username"
                shift
                case x$XAUTHORITY in
                x)
                        XAUTHORITY="$HOME/.Xauthority"
                        ;;
                esac
                case x$XUSERFILESEARCHPATH in
                x)
                        ;;
                *)
                        xpath="XUSERFILESEARCHPATH=$XUSERFILESEARCHPATH "
                        ;;
                esac
                ;;
        -access)
                shift
                xhost +$target
                ;;
        -name)
                shift
                label="$1"
                resource="$1"
                shift
                ;;
        -nols)
                shift
                ls=
                ;;
        -debug)
                shift
                redirect=
                ;;
        -screen)
                shift
                DISPLAY=`echo $DISPLAY | sed 's/:\\([0-9][0-9]*\\)\\.[0-9]/:\1/'`.$1
                shift
                ;;
        *)
                continue=false
                ;;
        esac
done
case x$XAUTHORITY in
x)
        ;;
x*)
        xauth="XAUTHORITY=$XAUTHORITY "
        ;;
esac
vars="$xpath$xauth"DISPLAY="$DISPLAY"
case $# in
0)
        $rcmd 'sh -c '"'$vars"' xterm '$ls' -name "'"$resource"'" -T "'"$label"'" -n "'"$label"'" '"$redirect'"
        ;;
*)
        $rcmd 'sh -c '"'$vars"' '"$*$redirect'"
        ;;
esac

X11r4 xon
Put it in /usr/local/bin and make it 755.

#! /bin/sh
#
# xon: start an X11 client on another host
#
# Runs the given command on another host with $DISPLAY set in the environment.
# Does an xhost to allow access to the other host.
# Xon is very careful not to leave any extra processes waiting
# around on either machine for the client to exit. In order
# to achieve this, csh is used on the remote host and all inputs
# and outputs are redirected to /dev/null.
# The -debug switch allows you to see errors, but doesn't worry about
# leaving extra processes around.
# If the given command starts with "xterm", it adds the arguments
# "-name xterm-$hostname"
# where $hostname is the name of the remote host. This allows
# you to customize your server's xrdb database to set attributes,
# such as the window color, based on the name of remote host.
#
# Written by Jim Dempsey <jjd@bbn.com> with help from Stephen Gildea
# <gildea@bbn.com> based on an idea by Dave Mankins <dm@think.com>.
# Originally written around 1987.
# Last modification Feb 4 1990 by dgreen@cs.ucla.edu

# Process xon options.

rshopts=""
while
  found=f
  case $1 in
    -debug )
      debug=t; set -xv; found=t
      ;;
    -l )
      shift; rshopts="-l $1 $rshopts"; found=t
      ;;
    esac
  [ $found = t ]
  do shift; done

case $# in
    0|1) echo "usage: $0 [-debug] [-l logname] host cmd [args]" 1>&2; exit 1;;
esac

host="$1"; shift
if [ ${HOSTNAME:-notset} = notset ] ; then HOSTNAME=`hostname` ; fi

command=$1; shift
if [ `basename $command` = "xterm" ]; then
    command="$command -name xterm-$host"
fi
if [ $# -ge 1 ]; then
    command="$command $@"
fi

# If run on the same host as server, modify $DISPLAY for the remote host.
case X$DISPLAY in
  Xunix:* | X:* )
    DISPLAY="`echo $DISPLAY | sed \"s/^[&:]*:/${HOSTNAME}:/\"`"
    export DISPLAY
    ;;
  esac

# If run on the same host as server, allow remote host access X server.
if [ $HOSTNAME != $host ]; then
    if [ "$debug" ]; then
        xhost +$host
    else
        xhost +$host > /dev/null 2>&1
    fi
fi

if type remsh | fgrep 'not found' > /dev/null
  then rshell=rsh
  else rshell=remsh
  fi

# Do the real work using rsh.
if [ "$debug" ]; then
    echo "$0: Going to execute \"$command\" on $host."
    $rshell $host $rshopts -n /bin/csh -cf "\"setenv DISPLAY $DISPLAY; setenv TERM xterm; $command\""
else
    case ${SHELL:-/bin/csh} in
      *csh )
         exec $rshell $host $rshopts -n \
              exec /bin/csh -cf "\"setenv DISPLAY $DISPLAY; setenv TERM xterm;\
                                   exec $command\" < /dev/null >& /dev/null"
         ;;
      * )
         exec $rshell $host $rshopts -n \
              exec /bin/csh -cf "\"setenv DISPLAY $DISPLAY; setenv TERM xterm;\
                                   exec $command\" < /dev/null > /dev/null 2>&1"
         ;;
      esac
fi

exit 0

I have not tried either one, so they may not work.

heasley@merl.com send this replacement for rsh.
-heas
"ps: try using this script called rcmd, instead of rsh.

#! /bin/sh
# This command runs a command remotely in the background, by pointing
# stdout and stderr at /dev/null. (Should we point stdin at /dev/null too?)
# By running this through the Bourne shell at the other end, and
# we get rid of the rsh and rshd which otherwise hand around at either
# end. Hacked from a posting by clyde@emx.utexas.edu to list.xpert
user=
HOST=${HOST-`hostname`}
if test $# -lt 2 ; then
        echo Usage: $0 remotehost remotecommand
        exit 1
else
        host=$1
        shift
        if test "$1" = "-l" ; then
                shift
                user=$1
                shift
        fi
fi
xhostname=`expr "$DISPLAY" : "\([^:]*\).*"`
xscreen=`expr "$DISPLAY" : "[^:]*\(.*\)"`
if test x$xscreen = x; then
        xscreen=":0.0"
fi
if test x$xhostname = x -o x$xhostname = x"unix"; then
        DISPLAY=$HOST$xscreen
fi
(
if test x$xhostname = x -o x$xhostname = x"unix" -o x$xhostname = x$HOST; then
        xhost +$host
fi
if test x$user = x; then
        echo "TERM=$TERM;export TERM;DISPLAY=$DISPLAY;export DISPLAY;($*)" '\
> /dev/null 2>&1 &' | rsh $host /bin/sh &
else
        echo "TERM=$TERM;export TERM;DISPLAY=$DISPLAY;export DISPLAY;($*)" '\
> /dev/null 2>&1 &' | rsh $host -l $user /bin/sh &
fi
) &"

Thanks to:
Henryk.Michalec@solidex.krakow.pl
fan@tammy.cath.upmc.edu (Ningping Fan)
lcollera@amgen.com (Lori Colleran)
allan@hyster.rain.com (Allan Warrior)
swb5600@sudcv91.ed.ray.com (Steven W. Bates
covingto@msmary.edu (Michael Covington)
jwelfeld@dasw.com (Joe Welfeld)
Ted Nolan SRI Ft Gordon <ted@ags.ga.erg.sri.com>
crossm1%frgen.dnet@sb.com
John Dillon <dillonj@ochampus.mil>
jor@dmsmodel.attmail.com (Jim O'Reilly)
rauthenberg@HHI.DE (Stefan Rauthenberg)
heasley@merl.com
slsherri@mtu.edu (Scott Sherrill)
cjudi@nesmgr.nlm.nih.gov (Judi Connelly)
siplem@npeeserv.eelab.newpaltz.edu (Matthew Siple)
dotty@hobbes.tgivan.wimsey.bc.ca (Dotty Pon)
Chip Christian <christian_chip@jpmorgan.com>
Lenny Turetsky <lturetsk@aida.econ.yale.edu>
jonsg@hyphen.com (Jon Green)
aspen!dbartle@jyacc.jyacc.com (David S. Bartle (NE))
Pat Max <pam@archie.lanl.gov>
russ@issi.com
"Kevin A. Noll" <knoll@csl-emh2.army.mil>
kontoudi@ics.forth.gr (Dimitris Kontoudis)
rwolf@dciem.dnd.ca (Robert Wolf)
mukher@airmics.gatech.edu (Amitesh Mukherjee)
tkevans@fallst.es.dupont.com (Tim Evans)
worsham@aer.com (Robert D. Worsham)

--
 ______________________________          ===================                  |
| David Burwell : 408-428-7929 |            T E L E C O M   
|           FAX : 408-428-7895 |         -------------------
|          Mail :              |          S O L U T I O N S 
| dburwell@telecom.telecom.com |         ===================
+------------------------------+     a division of Symmetricom Inc.



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:11 CDT