<?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 exit code vis SSH in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835881#M272437</link>
    <description>Its always zero because you are testing the exit code of your ssh command not the exit code of the command on the remote system. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 02 Aug 2006 09:42:31 GMT</pubDate>
    <dc:creator>Marvin Strong</dc:creator>
    <dc:date>2006-08-02T09:42:31Z</dc:date>
    <item>
      <title>Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835878#M272434</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt; All I want is to check the version of a software on a remote system through SSH. Thought of greping the version and then passing exit code, but it doesn't seems to be working. Any idea? or any better way of doing this. For eg.&lt;BR /&gt;&lt;BR /&gt;ssh &lt;REMOTE-SYSTEM&gt; "/usr/sbin/swlist xxx |grep 1234".&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;Shahul&lt;/REMOTE-SYSTEM&gt;</description>
      <pubDate>Wed, 02 Aug 2006 09:14:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835878#M272434</guid>
      <dc:creator>Shahul</dc:creator>
      <dc:date>2006-08-02T09:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835879#M272435</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;1) Try grep -i you may be failing a case sensitive issue.&lt;BR /&gt;&lt;BR /&gt;2) Return codes are passed by exit&lt;BR /&gt;&lt;BR /&gt;exit 1 bad&lt;BR /&gt;exit 0 good.&lt;BR /&gt;&lt;BR /&gt;Call a script on the remote node and have it with exit code based on success or failure.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 02 Aug 2006 09:18:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835879#M272435</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-08-02T09:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835880#M272436</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;  I think you missed my question. &lt;BR /&gt;&lt;BR /&gt;ssh &lt;REMOTE-SYSTEM&gt; "/usr/sbin/swlist xxx |grep 1234;echo $?"&lt;BR /&gt;&lt;BR /&gt;gives always "0", don't know why, it's same for remsh.&lt;BR /&gt;&lt;BR /&gt;#ssh &lt;REMOTE-SYSTEM&gt; "/usr/sbin/swlist xxx |grep 1234"&lt;BR /&gt;#echo $?&lt;BR /&gt;&lt;BR /&gt;This will also give always "0", because the SSH is always successful. I am looking for the exit code of "swlist | grep".&lt;BR /&gt;&lt;BR /&gt;Hope I made it clear.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Shahul&lt;/REMOTE-SYSTEM&gt;&lt;/REMOTE-SYSTEM&gt;</description>
      <pubDate>Wed, 02 Aug 2006 09:25:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835880#M272436</guid>
      <dc:creator>Shahul</dc:creator>
      <dc:date>2006-08-02T09:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835881#M272437</link>
      <description>Its always zero because you are testing the exit code of your ssh command not the exit code of the command on the remote system. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Aug 2006 09:42:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835881#M272437</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-02T09:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835882#M272438</link>
      <description>if you want to get the return code you have to do what steven said run a script and exit with the return code. &lt;BR /&gt;&lt;BR /&gt;ssh server /tmp/test&lt;BR /&gt;&lt;BR /&gt;test script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;swlist | grep 1234&lt;BR /&gt;exit $? &lt;BR /&gt;&lt;BR /&gt;then if you echo $? you should get the proper error code.</description>
      <pubDate>Wed, 02 Aug 2006 09:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835882#M272438</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-02T09:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835883#M272439</link>
      <description>*exit code not error code. &lt;BR /&gt;&lt;BR /&gt;guess im doing too many things at once today.</description>
      <pubDate>Wed, 02 Aug 2006 09:52:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835883#M272439</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-02T09:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Passing exit code vis SSH</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835884#M272440</link>
      <description>Here is what you should do:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;XX=$(ssh &lt;REMOTE-SYSTEM&gt; "/usr/sbin/swlist xxx |grep -q 1234; echo ${?}".&lt;BR /&gt;echo "XX = ${XX}" # will be 0 if 1234 was matched; 1 otherwise"&lt;BR /&gt;&lt;BR /&gt;an alternate approach:&lt;BR /&gt;ssh &lt;REMOTE-SYSTEM&gt; "/usr/sbin/swlist xxx |grep -q 1234; echo ${?}" | read XX&lt;BR /&gt;echo "XX = ${XX}" # will be 0 if 1234 was matched; 1 otherwise"&lt;BR /&gt;&lt;BR /&gt;Note that grep -q does its work silently and outputs nothing; we are only interested in a zero or non-zero exit status.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you test ${?} on the local host, all you are doing is testing whether or not ssh was able to be spawned.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/REMOTE-SYSTEM&gt;&lt;/REMOTE-SYSTEM&gt;</description>
      <pubDate>Wed, 02 Aug 2006 10:00:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-exit-code-vis-ssh/m-p/3835884#M272440</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-02T10:00:30Z</dc:date>
    </item>
  </channel>
</rss>

