Article View: comp.unix.programmer
Article #62ersh - rsh frontend hack returning exit status of remote cmd
From: Maarten Litmaath
Date: Wed, 30 Jan 1991 00:26
Date: Wed, 30 Jan 1991 00:26
70 lines
1337 bytes
1337 bytes
#!/bin/sh
# @(#)ersh 2.4 91/01/30 Maarten Litmaath
# This rsh front-end returns the exit status of the remote command.
# It works OK with sh/csh-compatible shells on the remote (!) side.
# If there is no remote command present, /usr/ucb/rlogin is invoked.
# Usage: see rsh(1).
unset hostname lflag nflag user
case $1 in
-l)
;;
*)
hostname=$1
shift
esac
case $1 in
-l)
lflag=-l
user=$2
shift 2
esac
case $1 in
-n)
nflag=-n
shift
esac
case $hostname in
'')
hostname=$1
shift
esac
case $# in
0)
exec /usr/ucb/rlogin $lflag ${user+"$user"} "$hostname"
esac
AWK='
NR > 1 {
print prev;
prev = $0;
prev1 = $1;
prev2 = $2;
}
NR == 1 {
prev = $0;
prev1 = $1;
prev2 = $2;
}
END {
if (prev1 ~ /[0-9]*[0-9]0/)
exit(prev1 / 10);
if (prev1 == "0")
exit(prev2);
print prev;
exit(1);
}
'
exec 3>&1
/usr/ucb/rsh "$hostname" $lflag ${user+"$user"} $nflag \
"(${*-:}); sh -c '"'echo "$0 $1" >&2'\'' $?0 "$status"' \
2>&1 >&3 3>&- | awk "$AWK" >&2 3>&-
--
Temporary files like /tmp/sh$$ are an abomination.
Technical Details
Message-ID:
<8877@star.cs.vu.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.programmer,alt.sources Subject: ersh - rsh frontend hack returning exit status of remote cmd Message-ID: <8877@star.cs.vu.nl> Date: 30 Jan 91 00:26:48 GMT