From: Bill Thompson (bill.thompson@GOODYEAR.COM)
Date: Wed Nov 06 2002 - 07:30:42 EST
Of course you can get this to work .... this is UNIX after all :-)
The problem is that because of the double quotes the local system is
evaluating the "$?" BEFORE you send it to the remote host. What you're
actually doing is: remsh rhost "date; echo 0"
So of course it always returns a zero.
To get this to work you can...
Use single quotes:
remsh rhost 'date; echo $?'
or use double quotes and escape the dollar sign:
remsh rhost "date; echo \$?"
examples:
-> remsh node5t1 'date; echo $?'
Wed Nov 6 07:21:13 EST 2002
0
-> remsh node5t1 'datkdajfk; echo $?'
ksh: datkdajfk: not found.
127
-> dsh -w node5t1 "datkdajfk; echo \$?"
hqgbi5t1: 127
hqgbi5t1: ksh: datkdajfk: not found.
Bill Thompson
Sr UNIX Systems Administrator
The Goodyear Tire & Rubber Co.
Contains Confidential and/or Proprietary Information
May Not Be Copied or Disseminated Without Express Consent of The Goodyear
Tire & Rubber Company.
AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2
----- Original Message -----
From: <fmu@OERAG.DE>
Newsgroups: bit.listserv.aix-l
To: <aix-l@Princeton.EDU>
Sent: Wednesday, November 06, 2002 6:32 AM
Subject: rsh and return code
> Hi *,
> I want to start a command on a remote node (whith rsh or dsh) and
> want like to know afterwards the return code
>
> For example:
>
> rsh <nodename> "date ; echo $?"
>
> But I don't get the right return code. I test it with a wrong command:
>
> # dsh -w styx "datkdajfk ; echo $?"
> styx: 0
> styx: ksh: datkdajfk: not found
> (root:hermes)[/]
>
> # rsh styx "datkdajfk ; echo $?"
> 0
> ksh: datkdajfk: not found.
> (root:hermes)[/]
> #
>
>
> Best regards,
> Frank Mueller
>
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:18 EDT