開始文字列によってプロセスが起動されるのは ttsession が動作しているホスト上だけですが、起動されたプロセスは他のホスト上の他のプロセスを起動できます。
そのためには、まず開始文字列を次のようにします。
# rsh farhost myprog |
次に、myprog を確実に正しいセッションに入れて初期メッセージを受信させるために、ToolTalk の重要な環境変数をいくつか伝播する必要があります。これには、例 4-1 に示すように、シェルスクリプトの ttrsh を使用します。
#! /bin/sh # Runs a command remotely in background, by pointing stdout and stderr # at /dev/null. By running this through the Bourne shell at the other end, # we get rid of the rsh and rshd. #set -x user= debug= HOST=${HOST-`hostname`} if [ "$1" = "-debug" ]; then debug=1 shift fi if [ $# -lt 2 -o "$1" = "-h" -o "$1" = "-help" ]; then echo "Usage: ttrsh [-debug] remotehost [-l username] ¥ remotecommand" echo "Usage: ttrsh [-h | -help]" 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 [ "$user" = "" ]; then userOption="" else userOption="-l $user" fi if [ $debug ]; then outputRedirect= else outputRedirect='> /dev/null 2>&1 &' fi ( echo "OPENWINHOME=$OPENWINHOME;export OPENWINHOME;¥ TT_SESSION=$TT_SESSION;export TT_SESSION;¥ TT_TOKEN=$TT_TOKEN;export TT_TOKEN;TT_FILE=$TT_FILE;¥ export TT_FILE;DISPLAY=$DISPLAY;export DISPLAY;($*)" ¥ $outputRedirect | rsh $host $userOption /bin/sh & ) & |