gaynor@busboys.rutgers.edu (Silver) (12/06/89)
shaw@paralogics.uucp writes: > [rsh's return code is simply indicates whether a connection could be > established or not?!] As far as I can tell, you are essentially correct. Tremendous pain in the ass. You really have to bend over backwards to get the return value - perhaps put it on the last line of stdout or stderr, and take it from there locally. Regards, [Ag]
maart@cs.vu.nl (Maarten Litmaath) (12/08/89)
In article <256@paralogics.UUCP> shaw@paralogics.UUCP (Guy Shaw) writes: \Rsh does not seem to pass back the return code from the command \executed on another machine. [...] \But, what about the good old Unix(TM)-philosophy tool-building approach? \You know, small general tools that do one job well, and all that. [...] Indeed! ----------8<----------8<----------8<----------8<----------8<---------- #!/bin/sh # @(#)ersh 2.1 89/12/07 Maarten Litmaath # this rsh front-end returns the exit status of the remote command # works OK with sh/csh-compatible shells on the remote side (!) # beware of `funny' chars in `status' when working in sh-compatible shells # if there is no remote command present, /usr/ucb/rlogin is invoked # usage: see rsh(1) hostname= lflag= nflag= case $1 in -l) ;; *) hostname=$1 shift esac case $1 in -l) lflag="-l $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 $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 $nflag "${*-:}"'; sh -c "echo $?0 $status >&2"' \ 2>&1 >&3 | awk "$AWK" >&2 -- `Take John Berryhill: the guy is everywhere! All because one day he typed "rn" instead of [rm]' (Richard Sexton) | maart@cs.vu.nl, uunet!mcsun!botter!maart