Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Help with RSH error status return Message-ID: <18536@mimsy.UUCP> Date: 13 Jul 89 21:33:20 GMT References: <201@camdev.UUCP> Distribution: usa Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <201@camdev.UUCP> sscott@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@mimsy.umd.edu Path: uunet!mimsy!chris