Help with RSH error status return

Chris Torek chris at mimsy.UUCP
Fri Jul 14 07:33:20 AEST 1989


In article <201 at camdev.UUCP> sscott at camdev.UUCP (Steve Scott) writes
[nb: this is my own summary]
	sh -c 'exit 3'
	echo $?
produces 3, but
	rsh otherhost 'exit 3'
	echo $?
produces 0.  The question is how to get at the `exit 3' that happens
on machine otherhost.

>Any hints/tips/ideas/pointers to the proper man pages/etc?

rsh (4BSD rsh, remote shell, not the `restricted' shell) will not
import the exit status of a remote command.  This is understandable
(how will you tell `remote process exit status is X' from `local
rsh exit status is X'?) but can be extremely annoying.

The only solution is to run a command on the remote machine that
runs the command that you want run, then passes back that command's
exit status.  E.g., instead of

	rsh otherhost mycmd

you need something like

	rsh otherhost myfrontend

where `myfrontend' is a program like this shell script:

	#! /bin/sh
	mycmd
	echo $?

This is not completely reliable; you have to write a more complex
protocol (such as that used by rcp) to tell whether things went well or
ill, and even that is not foolproof (as rcp sometimes demonstrates).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list