🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
1 messages
1 total messages Started by Maarten Litmaath Wed, 21 Nov 1990 16:13
Re: returning values from an rsh.
#86
Author: Maarten Litmaath
Date: Wed, 21 Nov 1990 16:13
96 lines
2290 bytes
In article <FRIDMAN.90Nov20121605@cs-sun-aa.cs>,
	fridman@cs-sun-aa.cs (fridman) writes:
)
)I need a way for an rsh to return the status of the last
)command that it executed on the remote machine. 

: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'ersh'
sed 's/^X//' > 'ersh' << '+ END-OF-FILE ''ersh'
X#!/bin/sh
X# @(#)ersh 2.1 89/12/07 Maarten Litmaath
X# this rsh front-end returns the exit status of the remote command
X# works OK with sh/csh-compatible shells on the remote side (!)
X# beware of `funny' chars in `status' when working in sh-compatible shells
X# if there is no remote command present, /usr/ucb/rlogin is invoked
X# usage: see rsh(1)
X
Xhostname=
Xlflag=
Xnflag=
X
Xcase $1 in
X-l)
X	;;
X*)
X	hostname=$1
X	shift
Xesac
X
Xcase $1 in
X-l)
X	lflag="-l $2"
X	shift 2
Xesac
X
Xcase $1 in
X-n)
X	nflag=-n
X	shift
Xesac
X
Xcase $hostname in
X'')
X	hostname=$1
X	shift
Xesac
X
Xcase $# in
X0)
X	exec /usr/ucb/rlogin $lflag $hostname
Xesac
X
XAWK='
X	NR > 1 {
X		print prev;
X		prev = $0;
X		prev1 = $1;
X		prev2 = $2;
X	}
X	NR == 1 {
X		prev = $0;
X		prev1 = $1;
X		prev2 = $2;
X	}
X	END {
X		if (prev1 ~ /[0-9]*[0-9]0/)
X			exit(prev1 / 10);
X		if (prev1 == "0")
X			exit(prev2);
X		print prev;
X		exit(1);
X	}
X'
X
Xexec 3>&1
X
X/usr/ucb/rsh $hostname $lflag $nflag "${*-:}"'; sh -c "echo $?0 $status >&2"' \
X	2>&1 >&3 | awk "$AWK" >&2
+ END-OF-FILE ersh
chmod 'u=rwx,g=rx,o=rx' 'ersh'
set `wc -c 'ersh'`
count=$1
case $count in
981)	:;;
*)	echo 'Bad character count in ''ersh' >&2
		echo 'Count should be 981' >&2
esac
exit 0
--
"Please DON'T BREAK THE CHAIN!  Terry Wood broke the chain and ended up
writing COBOL PROGRAMS.  Three days later, he found his Blue Star Tatoo
Letter, made 20 copies and mailed them out.  He found a good job writing
compilers."  --  tjw@unix.cis.pitt.edu (Terry J. Wood)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads