Finding the exit status of a command run on the remote shell

Finding the exit status of a command run on the remote shell

Post by Sridhar » Wed, 01 Aug 2001 00:20:02



Hai Everyone,

 I am writing a shell script which would run commands on the remote
shell (rsh -l login_name command). I need to write further code based
on the exit status of the command that is run on the remote shell. My
'rsh' command always returns '0' as the exit status, which I don't
need. Can anyone suggest me as to how I can find the exit status of a
command run on the remote shell?

Thanks in advance.

Sridhar G

 
 
 

Finding the exit status of a command run on the remote shell

Post by laura fairhe » Wed, 01 Aug 2001 11:08:58



Quote:>Hai Everyone,

> I am writing a shell script which would run commands on the remote
>shell (rsh -l login_name command). I need to write further code based
>on the exit status of the command that is run on the remote shell. My
>'rsh' command always returns '0' as the exit status, which I don't
>need. Can anyone suggest me as to how I can find the exit status of a
>command run on the remote shell?

one way you can do it is to output the exit status and capture
that to a variable;

rsh -K hostname sh -c 'false; echo $?' |read status
echo return status is $status

bye,

${L}

Quote:>Thanks in advance.

>Sridhar G


 
 
 

Finding the exit status of a command run on the remote shell

Post by laura fairhe » Wed, 01 Aug 2001 11:59:00




>>Hai Everyone,

>> I am writing a shell script which would run commands on the remote
>>shell (rsh -l login_name command). I need to write further code based
>>on the exit status of the command that is run on the remote shell. My
>>'rsh' command always returns '0' as the exit status, which I don't
>>need. Can anyone suggest me as to how I can find the exit status of a
>>command run on the remote shell?

>one way you can do it is to output the exit status and capture
>that to a variable;

>rsh -K hostname sh -c 'false; echo $?' |read status
>echo return status is $status

this workz a lot better of course (infinitely even);

status=`rsh -K hostname sh -c 'false; echo $?' `
echo return status is $status

the original version I posted (and didn't test, and
didn't even _think_ <g>) won't work because '|read status'
is executed in a sub-shell.

${L}

- Show quoted text -

Quote:

>bye,

>${L}

>>Thanks in advance.

>>Sridhar G

 
 
 

Finding the exit status of a command run on the remote shell

Post by Bill Marcu » Wed, 01 Aug 2001 19:23:35



>need. Can anyone suggest me as to how I can find the exit status of a
>command run on the remote shell?

I think it's in the FAQ which was posted earlier today:
rsh host -l username 'command; echo $?'
 
 
 

Finding the exit status of a command run on the remote shell

Post by Sridhar » Wed, 01 Aug 2001 21:46:30


Hai Laura,

  :)

  Thanks a million. It worked!!

regds,
Sridhar G

 
 
 

1. exit status from remote shell to local shell

     I'm trying to write a shell script that will run a command on one
     of our remote servers and return the exit status of that command
     back to the oringinating server.  I'm using rsh to do remote
     execution of the command on the other server, but I cannot figure
     out how to get the exit status of the command back to my local
     shell. Here is an example of what I've tried:

         (rsh ibm-sales proutil -C BUSY;retval=$?;export $retval)

     Any ideas of how I can do this???

     Clbe

-----------------------------------------------------------------------


                                      CIS:        72002,1027

2. rpcbind question

3. How to get the exit status of a remote command executed via rsh

4. sun sparc product history?

5. Exit status of remote commands

6. XF86Config screen problem

7. Retrieving Exit Status of remote command

8. apache feature test suite?

9. remote command's exit status

10. how to force rsh to exit with status of remote command

11. Remote shell exit status

12. exit status of shell command

13. exit status of the command in pipe from shell & named pipe