No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / appl / kx / rxtelnet.in
blobe937b6cb0414605c70776679f354c6288f96bfd8
1 #!/bin/sh
2 # $Heimdal: rxtelnet.in 13457 2004-03-07 17:22:06Z lha $
3 # $NetBSD$
5 usage="Usage: $0 [-l username] [-k] [-fF] [-t args_to_telnet] [-x args_to_xterm] [-K args_to_kx] [-w term_emulator] [-b telnet_binary] [-n] [-v] [-h | --help] [--version] host [port]"
6 binary=telnet
7 term=
8 kx_args=-P
9 while true
11 case $1 in
12 -l) telnet_args="${telnet_args} -l $2 "; kx_args="${kx_args} -l $2"; title="${2}@"; shift 2;;
13 -t) telnet_args="${telnet_args} $2 "; shift 2;;
14 -x) xterm_args="${xterm_args} $2 "; shift 2;;
15 -f) telnet_args="${telnet_args} -f"; shift;;
16 -F) telnet_args="${telnet_args} -F"; shift;;
17 -k) kx_args="${kx_args} -k"; shift;;
18 -K) kx_args="${kx_args} $2 "; shift 2;;
19 -n) term=none; shift;;
20 -w) term=$2; shift 2;;
21 -b) binary=$2; shift 2;;
22 --version) echo "$0: %PACKAGE% %VERSION%"; exit 0;;
23 -h) echo $usage; exit 0;;
24 --help) echo $usage; exit 0;;
25 -v) set -x; verb=1; shift;;
26 -*) echo "$0: Bad option $1"; echo $usage; exit 1;;
27 *) break;;
28 esac
29 done
30 if test $# -lt 1; then
31 echo $usage
32 exit 1
34 host=$1
35 port=$2
36 title="${title}${host}"
37 bindir=%bindir%
38 pdc_trams=`dirname $0`
39 PATH=$pdc_trams:$bindir:$PATH
40 export PATH
41 set -- `kx $kx_args $host`
42 if test $# -ne 3; then
43 echo "Warning: Cound not setup X forwarding"
44 pid=NO
45 disp=""
46 auth=""
47 else
48 screen=`echo $DISPLAY | sed -ne 's/[^:]*:[0-9]*\(\.[0-9]*\)/\1/p'`
49 pid=$1
50 disp=${2}${screen}
51 auth=$3
53 oldifs=$IFS
54 IFS=:
55 set -- $PATH
56 IFS=$oldifs
57 if test -z "$term"; then
58 for j in xterm dtterm aixterm dxterm hpterm; do
59 for i in $*; do
60 test -n "$i" || i="."
61 if test -x $i/$j; then
62 term=$j; break 2
64 done
65 done
67 test "$verb" && echo "Telnet command used is `type $binary`."
68 if test -n "$term" -a "$term" != "none"; then
69 ($term -title $title -n $title $xterm_args -e env DISPLAY=$disp XAUTHORITY=$auth $binary -D $telnet_args $host $port; test x"$pid" != xNO && kill -USR2 $pid) &
70 else
71 env DISPLAY=$disp XAUTHORITY=$auth $binary -D $telnet_args $host $port
72 test x"$pid" != xNO && kill -USR2 $pid