[comp.sources.x] v09i001: rterm, Patch1, Part01/01

tale@turing.cs.rpi.edu (David C Lawrence) (08/28/90)

Submitted-by: tale@rpi.edu (David C Lawrence)
Posting-number: Volume 9, Issue 1
Archive-name: rterm/patch1
Patch-To: Volume 8, Issue 74 (original: rterm 1.2)

The README update is the second diff.  I think there is a slight
problem here which didn't occur to me until just now; Makefile.dist
_was_ Makefile-dist.  Rename the latter to the former if you want to
keep mine around without having xmkf or such trash it.  Except for the
initial install stuff the other four targets should be interesting to
most people; that's why I didn't add them in Imakefile too.

Dave
-- 
   (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))
 The most remarkable thing about looking at a picture of myself was the sudden
   realisation that my hair is in fact parted on the left and not the right.

*** Makefile.dist-dist	Fri Aug 17 05:18:12 1990
--- Makefile.dist	Sun Aug 26 02:52:12 1990
***************
*** 4,6 ****
--- 4,21 ----
  	install -c -m 0755 rterm /usr/bin/X11/rterm
  	install -c -m 0444 RTerm.ad /usr/lib/X11/app-defaults/RTerm
  	install -c -m 0444 rterm.1 /usr/local/man/man1/rterm.1
+ 
+ shar:
+ 	makekit -m -p
+ 
+ patch:
+ 	rm -f Patch
+ 	for file in *; do if test -f $$file-dist; then \
+ 	  diff -c $$file-dist $$file >> Patch ; \
+ 	fi; done
+ 
+ clean:
+ 	rm -f MANIFEST.BAK Part01 Patch *~
+ 
+ donedist:
+ 	rm -f *-dist; chmod u-w *
*** README-dist	Mon Aug 20 00:37:08 1990
--- README	Sun Aug 26 02:31:20 1990
***************
*** 57,62 ****
--- 57,87 ----
  shorter than anything imake could come up with it, though you might
  need to make an edit or two to change the flags or paths.
  
+ rterm version 1.3
+ 
+ Fixed a problem with -login and rsh pointed out by Marty Ryba
+ <marty@pulsar.princeton.edu>; simply put, trying to use rsh with a
+ specified login name didn't work.
+ 
+ rlogin is now behaving consistently with telnet; both will xhost the
+ hostname to which they are connecting and both will hack the TERM
+ environment variable; telnet used to do neither.
+ 
+ Speaking of hacking the TERM variable, you can now turn this off if
+ you want.  Use the -term switch or resource.  See the manual page.
+ 
+ A -debug switch was added so errors from the rshed processes can be
+ visible.
+ 
+ It doesn't play with DISPLAY directly anymore because this would
+ potentially turn "unix:0" to the hostname display for local xterms
+ (telnet and rlogin) which it didn't need to do.
+ 
+ Resources only work unded X11R4 because apparenly R3 and earlier did
+ not have appres.  rterm checks for appres in /usr/bin/X11 (see the
+ "xprogs" variable at the top of the script if you need to change it)
+ and effectively skips the whole resource attempt if it doesn't find it.
+ 
                                   ----
  
  Comments, suggestions, whatever to David C Lawrence <tale@rpi.edu>.
*** RTerm.ad-dist	Sun Aug 26 02:14:37 1990
--- RTerm.ad	Sun Aug 26 02:15:07 1990
***************
*** 1,2 ****
--- 1,3 ----
  RTerm*method: rlogin
  RTerm*xpath: /usr/bin/X11
+ RTerm*term: xterm@display
*** patchlevel.h-dist	Sun Aug 26 02:14:22 1990
--- patchlevel.h	Sun Aug 26 02:15:40 1990
***************
*** 3,6 ****
   */
  
  #define VERSION 1
! #define PATCHLEVEL 2
--- 3,6 ----
   */
  
  #define VERSION 1
! #define PATCHLEVEL 3
*** rterm-dist	Wed Aug 15 23:34:53 1990
--- rterm	Sun Aug 26 02:14:14 1990
***************
*** 7,16 ****
  # be obtained from the FSF at 675 Massachusetts Ave, Cambridge MA 02139.
  #
  # modified to use RESOURCE_MANAGER on 13 Aug 90.
  # renamed to rterm on 15 Aug 90.
  #
! # telnet connexions are purposefully neither xhosted nor have the
! # $DISPLAY hack.  If you want it xhosted too use -xhost.
  #
  # /bin/csh is used on the remote end so rsh will exit; I am not a
  # Unix wizard to know why this must be so.  (I prefer the Bourne
--- 7,20 ----
  # be obtained from the FSF at 675 Massachusetts Ave, Cambridge MA 02139.
  #
  # modified to use RESOURCE_MANAGER on 13 Aug 90.
+ #
  # renamed to rterm on 15 Aug 90.
  #
! # don't change DISPLAY; use display.  better for local hosts rlogin/telnet.
! # changed handling of -l switch; rsh $login didn't work on 19 Aug 90.
! #
! # Added -term and -debug; make telnet work like rlogin for term type
! # and xhost purposes on 26 Aug 90.
  #
  # /bin/csh is used on the remote end so rsh will exit; I am not a
  # Unix wizard to know why this must be so.  (I prefer the Bourne
***************
*** 31,37 ****
  #
  # Author: tale@turing.cs.rpi.edu (David C Lawrence)
  
! PATH=/bin:/usr/bin:/usr/ucb:/usr/bin/X11
  export PATH
  
  args=/tmp/rterm$$args
--- 35,44 ----
  #
  # Author: tale@turing.cs.rpi.edu (David C Lawrence)
  
! # where you X programmes are
! # This is used for xterm, xhost, appres (if you have it)
! xprogs=/usr/bin/X11
! PATH=/bin:/usr/bin:/usr/ucb:$xprogs
  export PATH
  
  args=/tmp/rterm$$args
***************
*** 43,51 ****
  class=RTerm
  
  progname=`expr $0 : '.*/\(.*\)' \| $0`
! version="$progname version 1.2"
  usage="Usage: $progname host [-rlogin | -telnet | -rsh] [-label NAME] [-login NAME] \
!              [-xpath PATH] [-xhost HOST] [-h = -help] [-v = -version]"
  
  # I use cases; one less process to fork if test isn't a builtin.
  # This thing already has enough processes associated with it.
--- 50,59 ----
  class=RTerm
  
  progname=`expr $0 : '.*/\(.*\)' \| $0`
! version="$progname version 1.3"
  usage="Usage: $progname host [-rlogin | -telnet | -rsh] [-label NAME] [-login NAME] \
!               [-xpath PATH] [-xhost HOST] [-term TERM[@display]] [-debug]     \
!                 [-h = -help] [-v = -version]"
  
  # I use cases; one less process to fork if test isn't a builtin.
  # This thing already has enough processes associated with it.
***************
*** 69,84 ****
  # get resource defaults
  OIFS="$IFS"
  IFS=":$IFS"
! appres $class | while read resource value; do
    case $resource in
      $class[.*]$lh[.*]method|$class[.*]$dh[.*]method)echo 'method="'$value'"' ;;
      $class[.*]$lh[.*]label |$class[.*]$dh[.*]label) echo  'label="'$value'"' ;;
      $class[.*]$lh[.*]xpath |$class[.*]$dh[.*]xpath) echo  'xpath="'$value'"' ;;
      $class[.*]$lh[.*]login |$class[.*]$dh[.*]login) echo  'login="'$value'"' ;;
      $class\*method)                      echo 'method="${method:-'$value'}"' ;;
      $class\*xpath)                         echo 'xpath="${xpath:-'$value'}"' ;;
      $class\*label)                         echo 'label="${label:-'$value'}"' ;;
      $class\*login)                         echo 'login="${login:-'$value'}"' ;;
      $class[.*]$lh[.*]xhost|$class[.*]$dh[.*]xhost|$class\*xhost)
                                             echo xhosts=\"$xhosts $value\"    ;;
      # args we don't know about are handed as resources to xterm
--- 77,101 ----
  # get resource defaults
  OIFS="$IFS"
  IFS=":$IFS"
! # See if we have X11R4 appres
! if test -x $xprogs/appres; then
!   appres="appres $class"
!  else 
!   appres="cat < /dev/null"
! fi
! 
! $appres | while read resource value; do
    case $resource in
      $class[.*]$lh[.*]method|$class[.*]$dh[.*]method)echo 'method="'$value'"' ;;
      $class[.*]$lh[.*]label |$class[.*]$dh[.*]label) echo  'label="'$value'"' ;;
      $class[.*]$lh[.*]xpath |$class[.*]$dh[.*]xpath) echo  'xpath="'$value'"' ;;
      $class[.*]$lh[.*]login |$class[.*]$dh[.*]login) echo  'login="'$value'"' ;;
+     $class[.*]$lh[.*]term  |$class[.*]$dh[.*]term)  echo   'term="'$value'"' ;;
      $class\*method)                      echo 'method="${method:-'$value'}"' ;;
      $class\*xpath)                         echo 'xpath="${xpath:-'$value'}"' ;;
      $class\*label)                         echo 'label="${label:-'$value'}"' ;;
      $class\*login)                         echo 'login="${login:-'$value'}"' ;;
+     $class\*term)                          echo   'term="${term:-'$value'}"' ;;
      $class[.*]$lh[.*]xhost|$class[.*]$dh[.*]xhost|$class\*xhost)
                                             echo xhosts=\"$xhosts $value\"    ;;
      # args we don't know about are handed as resources to xterm
***************
*** 104,110 ****
  # provide some reasonable defaults even in lieu of any in resources
  # i hate when other programmes like XCalc don't do this.
  method="${method:-rlogin}"
! xpath="${xpath:-/usr/bin/X11}"
  
  case "$hostname" in
    -h | -help)
--- 121,129 ----
  # provide some reasonable defaults even in lieu of any in resources
  # i hate when other programmes like XCalc don't do this.
  method="${method:-rlogin}"
! xpath="${xpath:-$xprogs}"
! term="${term:-xterm@display}"
! debug=">&"
  
  case "$hostname" in
    -h | -help)
***************
*** 111,126 ****
      cat <<EOT
  $usage
  
- -rlogin:  xhost remote host, run xterm locally and rlogin to remote host.
  -rsh:     xhost remote host, rsh to remote host and run xterm there.
! -telnet:  run xterm locally and telnet to remote host.
  Default connexion method:  $method
  
  -label:   string for icon and title bar; defaults to first part of remote host.
  -login:   login name on remote host for rsh and rlogin; defaults to local name.
! -xpath:   Directory of xterm on remote host for rsh; default: $xpath.
! -xhost:   Additional name to xhost; usually an alias for the remote machine.
  
  The following will also be recognised if the first argument.
  -h or -help:    Print this message.
  -v or -version: Print version.  This is $version.
--- 130,148 ----
      cat <<EOT
  $usage
  
  -rsh:     xhost remote host, rsh to remote host and run xterm there.
! -rlogin:  xhost remote host, run xterm locally and rlogin to remote host.
! -telnet:  xhost remote host, run xterm locally and telnet to remote host.
  Default connexion method:  $method
  
  -label:   string for icon and title bar; defaults to first part of remote host.
  -login:   login name on remote host for rsh and rlogin; defaults to local name.
! -xpath:   directory of xterm on remote host for rsh; default: $xpath.
! -xhost:   additional name to xhost; usually an alias for the remote machine.
! -term:    terminal type for rlogin; default: $term.
  
+ -debug:   show any error messages from rsh; this leaves extra processes around.
+ 
  The following will also be recognised if the first argument.
  -h or -help:    Print this message.
  -v or -version: Print version.  This is $version.
***************
*** 144,153 ****
          $DISPLAY : ${localhostshort}: \| $DISPLAY : ${localhost}:` -ne 0; then
    # seemingly on the server; do xhost
    xhost=xhost
!   # put hostname in DISPLAY; potentially loses if localhost = localhostshort
!   DISPLAY=${localhost}:`expr $DISPLAY : '.*:\(.*\)'`
   else
    xhost=echo
  fi
  
  while :; do
--- 166,177 ----
          $DISPLAY : ${localhostshort}: \| $DISPLAY : ${localhost}:` -ne 0; then
    # seemingly on the server; do xhost
    xhost=xhost
!   # make sure hostname appears for remote hosts rather than unix or whatever;
!   # potentially loses if localhost = localhostshort
!   display=${localhost}:`expr $DISPLAY : '.*:\(.*\)'`
   else
    xhost=echo
+   display=$DISPLAY
  fi
  
  while :; do
***************
*** 157,169 ****
  
    # obviously, the last arg for mutually exclusive args is the victor.
    case "$1" in
!     -rlogin)	method=rlogin                ;;
!     -telnet)	method=telnet                ;;
!     -rsh)	method=rsh                   ;;
!     -label)	shift; label="$1"            ;;
!     -login)	shift; login="-l $1"         ;;
!     -xpath)     shift; xpath=$1              ;;
!     -xhost)     shift; xhosts="$xhosts $1"   ;;
      # pass the rest as arguments to xterm
      *) echo -n "\\\"$1\\\" " >> $args
    esac
--- 181,193 ----
  
    # obviously, the last arg for mutually exclusive args is the victor.
    case "$1" in
!     -rlogin|-telnet|-rsh) method=`expr $1 : '-\(.*\)'` ;;
!     -label)     shift;     label="$1"                  ;;
!     -login)     shift;     login="$1"                  ;;
!     -xpath)     shift;     xpath="$1"                  ;;
!     -xhost)     shift;    xhosts="$xhosts $1"          ;;
!     -term)      shift;      term="$1"                  ;;
!     -debug)                debug=">"                   ;;
      # pass the rest as arguments to xterm
      *) echo -n "\\\"$1\\\" " >> $args
    esac
***************
*** 170,175 ****
--- 194,202 ----
    shift
  done
  
+ # Make an arg for rsh/rlogin if we need to use a login name
+ login=${login:+"-l $login"}
+ 
  case $method in
    rsh)
      # This is wickedly ugly to the point of perversity.  I ended up using
***************
*** 181,203 ****
      # necessary.
      $xhost $xhosts $hostname > /dev/null
      command="\"$xpath/xterm -n \\\"$label\\\" -T \\\"$label\\\" \
!       -display $DISPLAY -ls `cat $args` \& \""
      $cleanup
!     exec rsh $hostname ${login:+"-l $login"} -n \
        echo \"$command\" \> '/tmp/rterm$$' \; \
        /bin/csh -cf "\"\`cat /tmp/rterm\$\$\` ; \
!          rm /tmp/rterm\$\$ \" < /dev/null >& /dev/null" ;;
!   rlogin)
      $xhost $xhosts $hostname > /dev/null
      command="xterm -n \"$label\" -T \"$label\" `eval echo \`cat $args\`` -e 
               sh -c 'export TERM; 
!              TERM=xterm@$DISPLAY exec rlogin $hostname ${login:+-l $login}'" 
!     eval exec $command & ;;
!   telnet)
!     $xhost $xhosts > /dev/null
!     command="xterm -n \"$label\" -T \"$label\" `eval echo \`cat $args\`` -e
!              telnet $hostname"
      eval exec $command & ;;
    *)
      echo $progname: bogus method: $method 1>&2 ; exit 1 ;;
  esac
--- 208,234 ----
      # necessary.
      $xhost $xhosts $hostname > /dev/null
      command="\"$xpath/xterm -n \\\"$label\\\" -T \\\"$label\\\" \
!       -display $display -ls `cat $args` \& \""
      $cleanup
!     exec rsh $hostname $login -n \
        echo \"$command\" \> '/tmp/rterm$$' \; \
        /bin/csh -cf "\"\`cat /tmp/rterm\$\$\` ; \
!          rm /tmp/rterm\$\$ \" < /dev/null $debug /dev/null" ;;
! 
!   rlogin|telnet)
!     type="`expr $term : '\(.*\)@'`"
!     if test "$type" = ""; then
!       type="$term"
!      else
!       type="$type@$display"
!     fi
! 
      $xhost $xhosts $hostname > /dev/null
      command="xterm -n \"$label\" -T \"$label\" `eval echo \`cat $args\`` -e 
               sh -c 'export TERM; 
!              TERM=$type exec $method $hostname $login'" 
      eval exec $command & ;;
+ 
    *)
      echo $progname: bogus method: $method 1>&2 ; exit 1 ;;
  esac
*** rterm.1-dist	Sun Aug 26 01:41:36 1990
--- rterm.1	Sun Aug 26 02:37:10 1990
***************
*** 15,23 ****
  .ta 8n
  \fBrterm\fP \fIhost\fP [-rlogin | -telnet | -rsh] [-label \fIname\fP]
  .br
! [-login \fIname\fP] [-xpath \fIpath\fP] [-xhost \fIhost\fP] [-h = -help]
  .br
! [-v = -version]
  .SH DESCRIPTION
  The
  .I rterm
--- 15,23 ----
  .ta 8n
  \fBrterm\fP \fIhost\fP [-rlogin | -telnet | -rsh] [-label \fIname\fP]
  .br
! [-login \fIname\fP] [-xpath \fIpath\fP] [-xhost \fIhost\fP]
  .br
! [-term \fIterm\fP[@display]] [-debug] [-h = -help] [-v = -version]
  .SH DESCRIPTION
  The
  .I rterm
***************
*** 42,72 ****
  These options follow the host argument to
  .I rterm.
  .TP 8
- .B \-rlogin
- Use
- .BR rlogin(1)
- to contact the remote host from a local
- .I xterm.
- The host will be added to your access control list by
- .I xhost
- if
- .I rterm
- is run on the server machine.
- Your
- .B DISPLAY
- environment variable is piggy-backed to the remote host on the
- .B TERM
- environment variable.  See
- .B EXAMPLES
- below for how you can interpret it.
- .TP 8
  .B \-rsh
  Use 
  .BR rsh(1)
  to establish the connexion to the remote host on which
  .I xterm
! is run.  The remote machine is added as with
! .B \-rlogin.
  .TP 8
  .B \-telnet
  Use
--- 42,59 ----
  These options follow the host argument to
  .I rterm.
  .TP 8
  .B \-rsh
  Use 
  .BR rsh(1)
  to establish the connexion to the remote host on which
  .I xterm
! is run.
! .TP 8
! .B \-rlogin
! Use
! .BR rlogin(1)
! to contact the remote host from a local
! .I xterm.
  .TP 8
  .B \-telnet
  Use
***************
*** 73,80 ****
  .BR telnet(1)
  to contact the remote host from a local
  .I xterm.
- The remote machine is not automatically added to your access control list.
  .LP
  A default connexion method is provided; which one is left to your local
  administrator's discretion.  The above methods are of course mutually
  exclusive. 
--- 60,72 ----
  .BR telnet(1)
  to contact the remote host from a local
  .I xterm.
  .LP
+ The machine named in the host argument will be added to your access
+ control list by
+ .I xhost
+ if
+ .I rterm
+ is run on the server machine.
  A default connexion method is provided; which one is left to your local
  administrator's discretion.  The above methods are of course mutually
  exclusive. 
***************
*** 103,108 ****
--- 95,120 ----
  .I rterm
  on the server.  This is especially useful if the remote machine enjoys
  a bit of schizophrenia and frequently goes by two names.
+ .TP 8
+ .B \-term \fIterm\fP
+ The terminal type to use on the remote machine.  This is available so
+ you have the possibility to pass the DISPLAY environment variable as
+ part of the TERM variable; see
+ .B EXAMPLES
+ below for a way to do this.  The \fIterm\fP argument is used as given
+ if it has no '@' in it.  If an '@' is present than everything before
+ it is kept and everything after it is replaced with the display name.
+ The default value as shipped is \fIxterm@display\fP
+ .TP 8
+ .B \-debug
+ This option is provided for use with
+ .B \-rsh
+ which has the side affect of closing its standard error so error
+ messages from the remote machine are lost.  When
+ .B \-debug
+ is given then any errors encountered while attempting to start
+ .I xterm
+ will be visible at the cost of keeping extra processes for the session.
  .LP
  Remaining arguments are passed to
  .I xterm.
***************
*** 159,164 ****
--- 171,178 ----
  .I rterm
  is run from the server machine.  Multiple hosts can appear on a single
  resource line.
+ .IP \fBRTerm[.HOST]*term\fP
+ The terminal type to use for \fIrlogin\fP or \fItelnet\fP connexions.
  .SH EXAMPLES
  A sample menu from \fI.twmrc\fP:
  .EX 0
***************
*** 201,212 ****
  backslashes are necessary.
  .LP
  The
- .B \-rlogin
- option sets the environment variable
- .B TERM
- to a form which looks like
  .B TERM@DISPLAY
! before making the connexion.  This can be interpreted during the login
  procedure at the remote host to correctly seperate the
  .B TERM
  and
--- 215,224 ----
  backslashes are necessary.
  .LP
  The
  .B TERM@DISPLAY
! form described for 
! .B \-term
! can be interpreted during the login
  procedure at the remote host to correctly seperate the
  .B TERM
  and
***************
*** 261,273 ****
  and moans that it is an unknown terminal type
  long before any user login file processing.
  .LP
- In order to facilitate getting the
- .B rsh
- process to vanish the standard file descriptors are directed to
- \fI/dev/null\fP.  This causes any errors from the remote shell or
- .B xterm
- to be lost.
- .LP
  Multiple machine names for the server could potentially make
  .I rterm
  think it isn't running on the server when it is; this can be prevented
--- 273,278 ----
***************
*** 323,335 ****
  .SH DIAGNOSTICS
  .I rterm
  doesn't have much to say since it figures any arguments it doesn't
! recognise are meant for xterm.  It will print a usage message if no
! arguments are given and it doesn't redirect the stderr of xhost.
! See
! .B BUGS
! above for the problem with rsh and the error of xterm.  Some
! diagnostics, like one indicating a bad hostname,  generated by other
! programmes, might not be seen because the window will disappear before
  the error message can be read in it.
  .TP 4
  "Permission denied."
--- 328,340 ----
  .SH DIAGNOSTICS
  .I rterm
  doesn't have much to say since it figures any arguments it doesn't
! recognise are meant for
! .I xterm.
! It will print a usage message if no
! arguments are given and it doesn't redirect the stderr of
! .I xhost.
! Some diagnostics, like rlogin indicating a bad hostname, might not be
! seen because the window will disappear before 
  the error message can be read in it.
  .TP 4
  "Permission denied."
***************
*** 341,348 ****
  .SH TODO
  These things might be implemented if anyone expresses a desire for
  them; send mail to the author.
- .IP \-
- a way to turn off the DISPLAY piggy-backing on TERM.
  .IP \-
  an RTerm.HOST.alias resource which could point to  the real name
  of a machine; resources should then be able to be read using  either
--- 346,351 ----

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.