<?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: multiple exit codes in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698573#M57341</link>
    <description>John&lt;BR /&gt;&lt;BR /&gt;Cool, thats great thanks&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Steve</description>
    <pubDate>Sun, 07 Apr 2002 03:22:10 GMT</pubDate>
    <dc:creator>steven Burgess_2</dc:creator>
    <dc:date>2002-04-07T03:22:10Z</dc:date>
    <item>
      <title>multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698566#M57334</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;This is a question from a recent query regarding a ping&lt;BR /&gt;&lt;BR /&gt;If i have a file &lt;HOSTS&gt; containing more than one hostname. I do&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=hosts&lt;BR /&gt;for host in $(cat $HOSTNAME)&lt;BR /&gt;do&lt;BR /&gt;ping $host -n 1 | grep -i received &amp;gt;&amp;gt; /tmp/success&lt;BR /&gt;done&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then grep -i $host /&lt;DIR&gt;/&lt;FILE&gt; &amp;gt;&amp;gt; /tmp/success2&lt;BR /&gt;&lt;BR /&gt;My question is, only the last hostname is recorded in success2&lt;BR /&gt;&lt;BR /&gt;How do I record each exit code from each grep&lt;BR /&gt;&lt;BR /&gt;ie&lt;BR /&gt;&lt;BR /&gt;have each hostname that is successful recorded in success2&lt;BR /&gt;&lt;BR /&gt;Thanks in adavance&lt;BR /&gt;&lt;BR /&gt;Steve&lt;/FILE&gt;&lt;/DIR&gt;&lt;/HOSTS&gt;</description>
      <pubDate>Sun, 07 Apr 2002 02:10:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698566#M57334</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T02:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698567#M57335</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=hosts &lt;BR /&gt;for host in $(cat $HOSTNAME) &lt;BR /&gt;do &lt;BR /&gt;ping $host -n 1 | grep -i received &amp;gt;&amp;gt; /tmp/success &lt;BR /&gt;done &lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;then grep -i $host /&lt;DIR&gt;/&lt;FILE&gt; &amp;gt;&amp;gt; /tmp/success2 &lt;BR /&gt;echo $? &amp;gt;&amp;gt; /tmp/success2&lt;BR /&gt;else&lt;BR /&gt;echo $? &amp;gt;&amp;gt; /tmp/success&lt;BR /&gt;fi&lt;/FILE&gt;&lt;/DIR&gt;</description>
      <pubDate>Sun, 07 Apr 2002 02:22:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698567#M57335</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T02:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698568#M57336</link>
      <description>Steven please ignore my last posting I misread your neds . try this&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=hosts &lt;BR /&gt;for host in $(cat $HOSTNAME) &lt;BR /&gt;do &lt;BR /&gt;ping $host -n 1 | grep -i received &amp;gt;&amp;gt; /tmp/success &lt;BR /&gt;echo $hosts "  " $? &amp;gt;&amp;gt; /tmp/grep_host_values&lt;BR /&gt;done &lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;then grep -i $host /&lt;DIR&gt;/&lt;FILE&gt; &amp;gt;&amp;gt; /tmp/success2 &lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;&lt;/DIR&gt;</description>
      <pubDate>Sun, 07 Apr 2002 02:39:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698568#M57336</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T02:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698569#M57337</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Sorry I don't think I explained correctly&lt;BR /&gt;&lt;BR /&gt;What I meant was&lt;BR /&gt;&lt;BR /&gt;Each grep produces an exit code ( success = 0)&lt;BR /&gt;(failure = 1)&lt;BR /&gt;&lt;BR /&gt;If the grep is a success then continue with the next grep from the hosts file&lt;BR /&gt;&lt;BR /&gt;So if all sites are up and ok their details from the /etc/hosts will be in success2 &lt;BR /&gt;&lt;BR /&gt;At the moment only the last hostname is&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sun, 07 Apr 2002 02:40:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698569#M57337</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T02:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698570#M57338</link>
      <description>John &lt;BR /&gt;&lt;BR /&gt;Your last post only returns the last exit code&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sun, 07 Apr 2002 02:44:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698570#M57338</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T02:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698571#M57339</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;sorry I didnt understand, your problem is the grep for details on hosts lies outside of the loop so is only performed on the last hostname in the list. Try this&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=hosts &lt;BR /&gt;for host in $(cat $HOSTNAME) &lt;BR /&gt;do &lt;BR /&gt;ping $host -n 1 | grep -i received &amp;gt;&amp;gt; /tmp/success &lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;then grep -i $host /&lt;DIR&gt;/&lt;FILE&gt; &amp;gt;&amp;gt; /tmp/success2 &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;John.&lt;/FILE&gt;&lt;/DIR&gt;</description>
      <pubDate>Sun, 07 Apr 2002 02:51:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698571#M57339</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T02:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698572#M57340</link>
      <description>Also&lt;BR /&gt;&lt;BR /&gt;The initial host file will be different each week.&lt;BR /&gt;&lt;BR /&gt;To build the host file i'm performing an ls &lt;FILE&gt; | cut -c16-22 &amp;gt; host&lt;BR /&gt;&lt;BR /&gt;Is there a sed command to replace all the entries in the host file to lowercase?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Steve&lt;/FILE&gt;</description>
      <pubDate>Sun, 07 Apr 2002 02:51:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698572#M57340</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T02:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698573#M57341</link>
      <description>John&lt;BR /&gt;&lt;BR /&gt;Cool, thats great thanks&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sun, 07 Apr 2002 03:22:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698573#M57341</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T03:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698574#M57342</link>
      <description>Steven&lt;BR /&gt;&lt;BR /&gt;Im still a little confused as to what your trying to do have a look at teh file attached I did a small similar script here and if you look at the output from the pings they all have received even when my network is presently switched off so I think you will have a problem.&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;John</description>
      <pubDate>Sun, 07 Apr 2002 03:25:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698574#M57342</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T03:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698575#M57343</link>
      <description>Steven&lt;BR /&gt;&lt;BR /&gt;Im betting you need to change your grep from bieng "recieved" to&lt;BR /&gt;&lt;BR /&gt;grep -v "100% packet loss"&lt;BR /&gt;&lt;BR /&gt;John.</description>
      <pubDate>Sun, 07 Apr 2002 03:32:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698575#M57343</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T03:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698576#M57344</link>
      <description>Hi John&lt;BR /&gt;&lt;BR /&gt;Basically, I have a whole bunch of files in a directory, within the file name is the hostname.&lt;BR /&gt;&lt;BR /&gt;I've extracted the hostname from the filename using the cut command and output to host. I then need to see if the hostname is available before initiating a connect direct process to resend the files to each server&lt;BR /&gt;&lt;BR /&gt;I did post another question regarding the connect direct part of the script&lt;BR /&gt;&lt;BR /&gt;I've only just done the scripting course so still trying to get used to all the syntax. I'm trying to automate all the boring stuff I have to done whilst on the support desk&lt;BR /&gt;&lt;BR /&gt;Here's the link to the other question&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xa1eb935c6049d611abda0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xa1eb935c6049d611abda0090277a778c,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I posted it in the wrong area so it may not have been picked up by all&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sun, 07 Apr 2002 03:57:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698576#M57344</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T03:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698577#M57345</link>
      <description>Hi Steven&lt;BR /&gt;&lt;BR /&gt;my last for today well its probably not the last of today but its 6am here in UK and I have been up all night so now I need some sleep before the kids get me.&lt;BR /&gt;&lt;BR /&gt;your description makes sense to me now and as I sad in my last post you definetly need to change the grep statement at the moment it will say all hosts are contactable even if they are down.&lt;BR /&gt;&lt;BR /&gt;later&lt;BR /&gt;John.</description>
      <pubDate>Sun, 07 Apr 2002 04:05:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698577#M57345</guid>
      <dc:creator>John Carr_2</dc:creator>
      <dc:date>2002-04-07T04:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698578#M57346</link>
      <description>Sorry to interfere with your discussion, but as far as i understand, you want a list of successes.&lt;BR /&gt;if you use $?, it will give you the returnvalue of the for-do-done statement, which always be a success since your for-do-done syntax is correct and always finish after the last host, therefor succes2 contains only the last hostname of the list.&lt;BR /&gt;&lt;BR /&gt;for&lt;BR /&gt;do&lt;BR /&gt; ping......&lt;BR /&gt;done&lt;BR /&gt;if [ $? ...&lt;BR /&gt;&lt;BR /&gt;should be&lt;BR /&gt;&lt;BR /&gt;for&lt;BR /&gt;do&lt;BR /&gt; ping .....&lt;BR /&gt; if [ $? ...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Now, $? gives the result of the ping it self.&lt;BR /&gt;I would suggest a script like:&lt;BR /&gt;&lt;BR /&gt;$HOSTFILE="/etc/hosts"&lt;BR /&gt;for host in `cat $HOSTFILE`&lt;BR /&gt;do&lt;BR /&gt; ping $host -n 2&lt;BR /&gt; if [ $? = 0 ]&lt;BR /&gt; then grep $host $HOSTFILE &amp;gt;&amp;gt; /tmp/pingablehosts&lt;BR /&gt; fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;,where /tmp/pingablehosts is the pingable subset of /etc/hosts.&lt;BR /&gt;&lt;BR /&gt;Success&lt;BR /&gt;Ceesjan</description>
      <pubDate>Sun, 07 Apr 2002 12:57:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698578#M57346</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-04-07T12:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: multiple exit codes</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698579#M57347</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply&lt;BR /&gt;&lt;BR /&gt;Yes your are right, this is what I ended up with&lt;BR /&gt;&lt;BR /&gt;host_name=hosts&lt;BR /&gt;for host in $(cat $host_name)&lt;BR /&gt;do&lt;BR /&gt;/etc/ping $host -n 1 | grep -q '1 packets received'&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "$host" &amp;gt;&amp;gt; /home/H092AHE/scripts/success&lt;BR /&gt;else&lt;BR /&gt;echo "$host" &amp;gt;&amp;gt; /home/H092AHE/scripts/failure&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Sun, 07 Apr 2002 17:43:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/multiple-exit-codes/m-p/2698579#M57347</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-04-07T17:43:58Z</dc:date>
    </item>
  </channel>
</rss>

