<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: passing result codes between servers and scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756939#M71616</link>
    <description>Hi John,&lt;BR /&gt;&lt;BR /&gt;for the first point i actually don't know a solution. Your second problem:&lt;BR /&gt;&lt;BR /&gt;--&amp;gt; I think the second script is called in the first script, is it?&lt;BR /&gt;---&amp;gt; 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:&lt;BR /&gt;&lt;BR /&gt;your_script_command_lines&lt;BR /&gt;exit 1&lt;BR /&gt;&lt;BR /&gt;In your first script put the following line immediately after exiting script 2:&lt;BR /&gt;&lt;BR /&gt;var=$?&lt;BR /&gt;&lt;BR /&gt;This remembers the exit code you gave to second script. &lt;BR /&gt;&lt;BR /&gt;echo $var would give you the exit value... 1&lt;BR /&gt;&lt;BR /&gt;You can give exit values from 0-255.&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
    <pubDate>Wed, 03 Jul 2002 09:07:20 GMT</pubDate>
    <dc:creator>Peter Kloetgen</dc:creator>
    <dc:date>2002-07-03T09:07:20Z</dc:date>
    <item>
      <title>passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756938#M71615</link>
      <description>I am running a script on a HP-UX 10.20 server that remotely runs a script on another server. How can I pass the result code of the remote script commands to the original server.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Thanks John</description>
      <pubDate>Wed, 03 Jul 2002 08:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756938#M71615</guid>
      <dc:creator>John McWilliams</dc:creator>
      <dc:date>2002-07-03T08:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756939#M71616</link>
      <description>Hi John,&lt;BR /&gt;&lt;BR /&gt;for the first point i actually don't know a solution. Your second problem:&lt;BR /&gt;&lt;BR /&gt;--&amp;gt; I think the second script is called in the first script, is it?&lt;BR /&gt;---&amp;gt; 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:&lt;BR /&gt;&lt;BR /&gt;your_script_command_lines&lt;BR /&gt;exit 1&lt;BR /&gt;&lt;BR /&gt;In your first script put the following line immediately after exiting script 2:&lt;BR /&gt;&lt;BR /&gt;var=$?&lt;BR /&gt;&lt;BR /&gt;This remembers the exit code you gave to second script. &lt;BR /&gt;&lt;BR /&gt;echo $var would give you the exit value... 1&lt;BR /&gt;&lt;BR /&gt;You can give exit values from 0-255.&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 03 Jul 2002 09:07:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756939#M71616</guid>
      <dc:creator>Peter Kloetgen</dc:creator>
      <dc:date>2002-07-03T09:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756940#M71617</link>
      <description>Hi John,&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;exit 2 &lt;BR /&gt;exit $Variable&lt;BR /&gt;&lt;BR /&gt;Between two boxes with remsh you can call the second script as:&lt;BR /&gt;Script1 in host1&lt;BR /&gt;var=$(remsh host2 -n scriptname)&lt;BR /&gt;&lt;BR /&gt;Script2 in host2&lt;BR /&gt;echo "2"&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;Justo.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Jul 2002 09:08:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756940#M71617</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-07-03T09:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756941#M71618</link>
      <description>On the same machine you can put the code into a variable and then export the variable. ie &lt;BR /&gt;&lt;BR /&gt;RESULT=value&lt;BR /&gt;export RESULT&lt;BR /&gt;&lt;BR /&gt;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 ?</description>
      <pubDate>Wed, 03 Jul 2002 09:09:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756941#M71618</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2002-07-03T09:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756942#M71619</link>
      <description>I think your second question (2 scripts on same server) has been answered, so I will only address your first question (2 scripts on 2 servers).&lt;BR /&gt;&lt;BR /&gt;Write the exit code with an echo command and use command substitution (`....`) to put it in a local variable.&lt;BR /&gt;&lt;BR /&gt;A small example:&lt;BR /&gt;&lt;BR /&gt;$ remsh remote_sys "ll found"&lt;BR /&gt;-rw-r--r--   1 franks     ftp_group        0 Jul  3 17:04 found&lt;BR /&gt;$ remsh remote_sys "ll not_found"&lt;BR /&gt;not_found not found&lt;BR /&gt;$ remsh remote_sys "cat doit"&lt;BR /&gt;ll $1 &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;echo $?&lt;BR /&gt;$ result=`remsh remote_sys "doit found"`&lt;BR /&gt;$ echo $result&lt;BR /&gt;0&lt;BR /&gt;$ result=`remsh remote_sys "doit not_found"`&lt;BR /&gt;$ echo $result&lt;BR /&gt;2&lt;BR /&gt;$</description>
      <pubDate>Wed, 03 Jul 2002 14:10:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756942#M71619</guid>
      <dc:creator>Frank Slootweg</dc:creator>
      <dc:date>2002-07-03T14:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: passing result codes between servers and scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756943#M71620</link>
      <description>Hi John:&lt;BR /&gt;&lt;BR /&gt;I'll address your first question since the other has been covered.&lt;BR /&gt;&lt;BR /&gt;Your question has come up many times. I will simply duplicate one of my earlier posts. &lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;REM_ERR_FILE=/var/tmp/x${$}.err &lt;BR /&gt;remsh remote_host my_command ${REM_ERR_FILE} &lt;BR /&gt;LOCAL_STAT=$? &lt;BR /&gt;&lt;BR /&gt;${LOCAL_STAT} only tells us about the success of remsh itself &lt;BR /&gt;&lt;BR /&gt;Now my_command on the remote host can get the &lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;When the remsh command finishes you can then &lt;BR /&gt;REM_STAT=$(remsh remote_host cat ${REM_ERR_FILE}) &lt;BR /&gt;to capture the remote commands status. (You should then issue a final remsh to remove the ${REM_ERR_FILE}.) &lt;BR /&gt;&lt;BR /&gt;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. &lt;BR /&gt;&lt;BR /&gt;You can serach the Forums for remsh and status for other methods.&lt;BR /&gt;Regards, Clay &lt;BR /&gt;</description>
      <pubDate>Wed, 03 Jul 2002 14:21:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-result-codes-between-servers-and-scripts/m-p/2756943#M71620</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-07-03T14:21:58Z</dc:date>
    </item>
  </channel>
</rss>

