Just make a copy of the cksum instead of trying to work around the
[heimdal.git] / appl / kx / rxtelnet.in
blobd5cf010f2f65dc92cb4aad84d6cfe879ff5e850c
1 #!/bin/sh
2 # $Id$
4 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]"
5 binary=telnet
6 term=
7 kx_args=-P
8 while true
9 do
10 case $1 in
11 -l) telnet_args="${telnet_args} -l $2 "; kx_args="${kx_args} -l $2"; title="${2}@"; shift 2;;
12 -t) telnet_args="${telnet_args} $2 "; shift 2;;
13 -x) xterm_args="${xterm_args} $2 "; shift 2;;
14 -f) telnet_args="${telnet_args} -f"; shift;;
15 -F) telnet_args="${telnet_args} -F"; shift;;
16 -k) kx_args="${kx_args} -k"; shift;;
17 -K) kx_args="${kx_args} $2 "; shift 2;;
18 -n) term=none; shift;;
19 -w) term=$2; shift 2;;
20 -b) binary=$2; shift 2;;
21 --version) echo "$0: %PACKAGE% %VERSION%"; exit 0;;
22 -h) echo $usage; exit 0;;
23 --help) echo $usage; exit 0;;
24 -v) set -x; verb=1; shift;;
25 -*) echo "$0: Bad option $1"; echo $usage; exit 1;;
26 *) break;;
27 esac
28 done
29 if test $# -lt 1; then
30 echo $usage
31 exit 1
33 host=$1
34 port=$2
35 title="${title}${host}"
36 bindir=%bindir%
37 pdc_trams=`dirname $0`
38 PATH=$pdc_trams:$bindir:$PATH
39 export PATH
40 set -- `kx $kx_args $host`
41 if test $# -ne 3; then
42 echo "Warning: Cound not setup X forwarding"
43 pid=NO
44 disp=""
45 auth=""
46 else
47 screen=`echo $DISPLAY | sed -ne 's/[^:]*:[0-9]*\(\.[0-9]*\)/\1/p'`
48 pid=$1
49 disp=${2}${screen}
50 auth=$3
52 oldifs=$IFS
53 IFS=:
54 set -- $PATH
55 IFS=$oldifs
56 if test -z "$term"; then
57 for j in xterm dtterm aixterm dxterm hpterm; do
58 for i in $*; do
59 test -n "$i" || i="."
60 if test -x $i/$j; then
61 term=$j; break 2
63 done
64 done
66 test "$verb" && echo "Telnet command used is `type $binary`."
67 if test -n "$term" -a "$term" != "none"; then
68 ($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) &
69 else
70 env DISPLAY=$disp XAUTHORITY=$auth $binary -D $telnet_args $host $port
71 test x"$pid" != xNO && kill -USR2 $pid