home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / contrib / rxterm / rx-sh next >
Text File  |  1995-07-03  |  2KB  |  94 lines

  1. #!/bin/sh
  2. #
  3. # Original Author: fm@mirsa.fr , modified by H.Leroy
  4.  
  5. rx()
  6. { shift; comm="$*"
  7.  
  8.    if [ "$mach" = "$HOSTNAME" ]
  9.    then
  10.         # eval to have double evaluation as when using rsh
  11.         # Hack: use "| :" instead of "&" to spawn a process in background
  12.     # without catching INT and QUIT (for a bug of xterm X10)
  13.     eval "$comm < /dev/null > $logf 2>&1 | :"
  14.    else
  15.         # Rshd  open one file-descriptor (number 7 often) and does'nt terminate
  16.         # before its closing!!!!
  17.         # Cshell close first every file-descriptors ...
  18.         # ~~ Assume that the remote shell is the same that the current one
  19.      if [ "$mach" = "mirsa" -o "$mach" = "mirsa.inria.fr" ]
  20.      then PATH=/usr/bin/X11:$PATH
  21.           export PATH
  22.      fi        
  23.  
  24. # valider :
  25.  
  26.     xhost +$mach > /dev/null
  27.  
  28.         case $SHELL in
  29.           *csh* )
  30.         rsh $mach "setenv PATH $PATH; setenv DISPLAY $DISPLAY; \
  31.         setenv MANPATH $MANPATH; \
  32.         exec $comm </dev/null >&! $logf"
  33.         ;;
  34.       *sh* )rsh $mach "PATH=$PATH DISPLAY=$DISPLAY MANPATH=$MANPATH; \
  35.                 export PATH DISPLAY MANPATH ; \
  36.         $comm < /dev/null > $logf 2>&1 \
  37.         3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 9>&1 \
  38.         3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&- | :"
  39.         ;;
  40.           * )
  41.         echo "Unknown shell: SHELL=$SHELL"
  42.         exit 10
  43.         ;;
  44.     esac
  45.  fi
  46. }
  47.  
  48. rxterm()
  49. { shift;
  50.  
  51.     [ "$mach" != "$HOSTNAME" ] && set -- -ls "$@"    # Login shell if remote
  52.     case $* in
  53.       *-e* )
  54. # Extract the entry name of the command to execute
  55.         name=`echo $* | sed -e "s/^.*-e //" | awk '{print $1}'`
  56.          if [ -z "$name" ]
  57.           then echo "missing command name for -e switch" ;exit 1
  58.          fi
  59.         name=`basename $name`@$mach        # Ex: emacs@mirsa
  60.         ;;
  61.       * )
  62.         # Just the machine name
  63.         name=$mach
  64.         ;;
  65.     esac
  66.     # Use of -n and not -T to be compatible with X10
  67.     # X11 xterm uses -n to specify the icon name but default the title name
  68.     # with the icon name
  69.  
  70.    rx $mach xterm -n $name "$@"
  71. }
  72.  
  73. rxload()
  74. {  shift;   rx $mach xload "$@"
  75. }
  76.  
  77. logf='${HOME}/.rx.log'
  78.  
  79. mach=$1;
  80. HOSTNAME=`hostname 2> /dev/null || uuname -l `
  81. xscreen=`expr "$DISPLAY" : "[^:]*\(.*\)"`
  82. if [ $xscreen = x ]
  83. then
  84.     xscreen=":0.0"
  85. fi
  86.     DISPLAY=unix:0
  87.  
  88. if [ "$HOSTNAME" != "$mach" ]
  89. then
  90.     DISPLAY=${HOSTNAME}$xscreen
  91. fi
  92.  
  93.     `basename $0` "$@"
  94.