- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: passing result codes between servers and scrip...
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
Forums
Discussions
Discussions
Discussions
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
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
07-03-2002 01:50 AM
07-03-2002 01:50 AM
passing result codes between servers and scripts
I also run 2 scripts on the same server and want to pass the result code fromthe second script to the first. How can I do this.
Thanks John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 02:07 AM
07-03-2002 02:07 AM
Re: passing result codes between servers and scripts
for the first point i actually don't know a solution. Your second problem:
--> I think the second script is called in the first script, is it?
---> Then you could call it and in the script you leave the second script with an exit- command which enables you to get the desired exitcode. Enter the following lines into your script:
your_script_command_lines
exit 1
In your first script put the following line immediately after exiting script 2:
var=$?
This remembers the exit code you gave to second script.
echo $var would give you the exit value... 1
You can give exit values from 0-255.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 02:08 AM
07-03-2002 02:08 AM
Re: passing result codes between servers and scripts
Between scripts you can use the $? variable in order to know the return value, and in the second script you must put the exit command with a value like this:
exit 2
exit $Variable
Between two boxes with remsh you can call the second script as:
Script1 in host1
var=$(remsh host2 -n scriptname)
Script2 in host2
echo "2"
exit
Hope this helps,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 02:09 AM
07-03-2002 02:09 AM
Re: passing result codes between servers and scripts
RESULT=value
export RESULT
I have not tried exporting to other servers but if it doesn't work why not put the result in a temp file available to both servers ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 07:10 AM
07-03-2002 07:10 AM
Re: passing result codes between servers and scripts
Write the exit code with an echo command and use command substitution (`....`) to put it in a local variable.
A small example:
$ remsh remote_sys "ll found"
-rw-r--r-- 1 franks ftp_group 0 Jul 3 17:04 found
$ remsh remote_sys "ll not_found"
not_found not found
$ remsh remote_sys "cat doit"
ll $1 >/dev/null 2>&1
echo $?
$ result=`remsh remote_sys "doit found"`
$ echo $result
0
$ result=`remsh remote_sys "doit not_found"`
$ echo $result
2
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2002 07:21 AM
07-03-2002 07:21 AM
Re: passing result codes between servers and scripts
I'll address your first question since the other has been covered.
Your 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