<?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 How to return a value from a shell script on Linux to a calling program on Hp Tru64 UNIX in Operating System - Tru64 Unix</title>
    <link>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280248#M4145</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;   I am trying to return a value to a calling program on HP Tru64 UNIX from a shell script on Linux. In the program on linux, I use FTP to get a file and handle errors like unable to login etc. These errors are handled by doing a grep on the log file for "Unable to login" text and assigning a value to a variable called Login a value of 1 if the process could not login to the FTP Site. When this error occurs, I do a exit 1 but befor doing this, I want to return a value to the calling program to indicate that this process has failed and would like to use this returned value in the calling program to echo a message saying that the program has failed. How can I achieve this? Please advise.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Aishwarya.</description>
    <pubDate>Fri, 03 Oct 2008 02:08:44 GMT</pubDate>
    <dc:creator>AKB_1</dc:creator>
    <dc:date>2008-10-03T02:08:44Z</dc:date>
    <item>
      <title>How to return a value from a shell script on Linux to a calling program on Hp Tru64 UNIX</title>
      <link>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280248#M4145</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;   I am trying to return a value to a calling program on HP Tru64 UNIX from a shell script on Linux. In the program on linux, I use FTP to get a file and handle errors like unable to login etc. These errors are handled by doing a grep on the log file for "Unable to login" text and assigning a value to a variable called Login a value of 1 if the process could not login to the FTP Site. When this error occurs, I do a exit 1 but befor doing this, I want to return a value to the calling program to indicate that this process has failed and would like to use this returned value in the calling program to echo a message saying that the program has failed. How can I achieve this? Please advise.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Aishwarya.</description>
      <pubDate>Fri, 03 Oct 2008 02:08:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280248#M4145</guid>
      <dc:creator>AKB_1</dc:creator>
      <dc:date>2008-10-03T02:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a value from a shell script on Linux to a calling program on Hp Tru64 UNIX</title>
      <link>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280249#M4146</link>
      <description>&lt;!--!*#--&gt;What's "a calling program on HP Tru64 UNIX"?&lt;BR /&gt;&lt;BR /&gt;Are you doing something like this on the&lt;BR /&gt;Tru64 system?:&lt;BR /&gt;      rsh linux_host shell_script [args]&lt;BR /&gt;&lt;BR /&gt;If so, then on the Tru64 system, the exit&lt;BR /&gt;status from the rsh command won't tell you&lt;BR /&gt;what the exit status was from the remote&lt;BR /&gt;command, so, as you've seen, "exit 1" there&lt;BR /&gt;does nothing for you.&lt;BR /&gt;&lt;BR /&gt;The remote script _can_ write text to stdout&lt;BR /&gt;and/or stderr, and this can be examined by&lt;BR /&gt;the person or process which does the rsh.&lt;BR /&gt;For example, instead of&lt;BR /&gt;      exit $sts&lt;BR /&gt;you could write it back on stderr:&lt;BR /&gt;&lt;BR /&gt;dy # cat test.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;echo "$1"&lt;BR /&gt;sts=$(( "$1" + "$1" ))&lt;BR /&gt;echo "sts=$sts" &amp;gt;&amp;amp;2&lt;BR /&gt;&lt;BR /&gt;(I have an HP-UX system up at the moment, so&lt;BR /&gt;pretend that "remsh" is "rsh".)&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy './test.sh 3'&lt;BR /&gt;sts=6&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;Here, the "3" was on stdout, and "sts=6" was&lt;BR /&gt;on stderr.  If we redirect stdout:&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy './test.sh 3' &amp;gt; /dev/null&lt;BR /&gt;sts=6&lt;BR /&gt;&lt;BR /&gt;then only the status string is seen.&lt;BR /&gt;&lt;BR /&gt;The best way to do this may depend on what&lt;BR /&gt;the remote script is doing with stdout and&lt;BR /&gt;stderr now.  If nothing, then you can do&lt;BR /&gt;practically anything you wish.  One advantage&lt;BR /&gt;to using stderr for the status string is that&lt;BR /&gt;complaints from real problems will also go to&lt;BR /&gt;stderr:&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy './test.sh fred' &amp;gt; /dev/null&lt;BR /&gt;./test.sh[3]:  fred + fred : The specified number is not valid for this command.</description>
      <pubDate>Fri, 03 Oct 2008 02:56:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280249#M4146</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-10-03T02:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to return a value from a shell script on Linux to a calling program on Hp Tru64 UNIX</title>
      <link>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280250#M4147</link>
      <description>Hi Aishwarya,&lt;BR /&gt;&lt;BR /&gt;I'm not entirely sure how you're running things, however searching a log file for errors is likely to give you problems.&lt;BR /&gt;&lt;BR /&gt;If I were you I would rewrite the script in Perl, using the Net::FTP module.  This allows for much better error handling.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Rob&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Oct 2008 08:20:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-tru64-unix/how-to-return-a-value-from-a-shell-script-on-linux-to-a-calling/m-p/4280250#M4147</guid>
      <dc:creator>Rob Leadbeater</dc:creator>
      <dc:date>2008-10-03T08:20:35Z</dc:date>
    </item>
  </channel>
</rss>

