SUMMARY:rsh and return code

From: Simon-Bernard Drolet (Simon-Bernard.Drolet@M3iSystems.com)
Date: Wed Dec 10 1997 - 15:41:01 CST


Here is my question:

>
> Hi Sunners,
>
> >From a sh script, I would like to start a command in background on a
> remote system and capture the return code of that start to make sure the
> command on the remote node started.
>
> How can I achieved this ? Because I need to trap if the command I'm
> trying to execute is started in background but I don't wan't to wait for
> it, just wait enough to know that it is started.
>
> Thank's and I will summerize.
>
> PS: Here what I'm trying now and doesn't work:
>
> code=`\remsh remote_node -n "a_shell_script_pgm 1>&- 2>&- &"' ; echo $?`
>
> But it doesn't work! If I remove the &, it does ! But I must wait for
> the completion of
> a_shell_script_pgm.
> --
> Simon-Bernard Drolet mailto:Simon-Bernard.Drolet@M3iSystems.QC.CA
> Unix System Administrator Tel: (514) 928-3386 ext. 2330
> M3i Systems Inc. Fax: (514) 442-5076
> Longueuil, Quebec, Canada http://www.M3iSystems.QC.CA

Finally, I came up with something like this:

output=`\rsh remotenode -n "/usr/bin/remote_command &" 2>&1`

After that line, I can test $? to make sure the "rsh" worked !

Next, I can test if the variable $output is empty, if so, the remote
command succeed ! (Well in my case, succeed means it's started).

Normally, when there is an error, the shell says something like
"permission denied", file not found, etc...

If the remote command fails after start-up, I rely on that command to
syslog the event ! (In my case, the remote command is a in-house
script...)

Thank's to the following:

Tony Clark <tonycl@msi-uk.com>
Jim Harmon <jim@telecnnct.com>
seeger@cise.ufl.edu (Charles Seeger)
Kevin.Sheehan@uniq.com.au (Kevin Sheehan {Consulting Poster Child}
Joseph S D Yao <jsdy@tux.org>

Simon.

-- 
Simon-Bernard Drolet      mailto:Simon-Bernard.Drolet@M3iSystems.QC.CA
Unix System Administrator Tel: (514) 928-3386 ext. 2330
M3i Systems Inc.          Fax: (514) 442-5076
Longueuil, Quebec, Canada http://www.M3iSystems.QC.CA



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:11 CDT