- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Test return value from remsh'd script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:47 AM
тАО01-10-2002 05:47 AM
Thanks
Hamish
Has anyone experienced the same queries
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:53 AM
тАО01-10-2002 05:53 AM
Re: Test return value from remsh'd script
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:55 AM
тАО01-10-2002 05:55 AM
Re: Test return value from remsh'd script
It depends what your remote script does. If it does not have anything doing to standard out, you can do something like this
VAL=`remsh node script.sh`
#####
Script.sh
code
...
echo $RETRUN_VAL
or you could do something like this
remsh node script.sh
VAL=`remsh cat ret_file`
#####
Script.sh
code
...
echo $RETURN_VAL > ret_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:56 AM
тАО01-10-2002 05:56 AM
Re: Test return value from remsh'd script
Yes that question has come up many times. I will simply duplicate one of my earlier posts.
NOTE: This is the most general solution to the problem when you also need STDOUT and STDERR from your remsh'ed process. i.e. This method works in all cases.
The remsh exit code of 0 only means that the script was able to be launched. The exit status of the remote command is not returned. There is a workaround I have used for a long time.
REM_ERR_FILE=/var/tmp/x${$}.err
remsh remote_host my_command $REM_ERR_FILE
LOCAL_STAT=$?
$LOCAL_STAT only tells us about the success of remsh itself
Now my_command on the remote host can get the
value of $REM_ERR_FILE; any status values you are interested in can be written to that file by your script on the remote host.
When the remsh command finishes you can then
REM_STAT=`remsh remote_host cat ${REM_ERR_FILE}`
to capture the remote commands status. (You should then issue a final remsh to remove the $REM_ERR_FILE.)
It's a little complicated but it does work. Since we generate a process id dependent filename on the local host, you don't have to worry about filename collision when multiple instances are running. This method also leaves stderr and stdout for their normal use.
You can serach the Forums for remsh and status for other methods.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:56 AM
тАО01-10-2002 05:56 AM
Re: Test return value from remsh'd script
Here is an example i use (in a Ksh Shell). The Idea: Put the value of the return remsh in a variable, and test that variable afterwards.
CMD_RELEASE_DSK="/usr/bin/remsh $SERVEUR_CIBLE -l root -n '${SHELL_CONTROL_SERVEUR_CIBLE} RELEASE ; echo $?'"
RESULT=`eval ${CMD_RELEASE_DSK}`
if [ $RESULT -eq 0 ] ; then
echo "Ok"
else
echo "Ko"
fi
It may help
regards
PJA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2002 05:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2006 04:25 AM
тАО10-27-2006 04:25 AM
Re: Test return value from remsh'd script
Robin's solution needs a modification :
remsh host "your_script;echo \$?" > /tmp/returncode
or use simple quotes instead.