<?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: while loop help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054339#M94374</link>
    <description>Chris,&lt;BR /&gt;&lt;BR /&gt;-w is not an option for ping under HPUX.&lt;BR /&gt;Can you try without this option</description>
    <pubDate>Tue, 14 Aug 2007 08:16:09 GMT</pubDate>
    <dc:creator>Luk Vandenbussche</dc:creator>
    <dc:date>2007-08-14T08:16:09Z</dc:date>
    <item>
      <title>while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054338#M94373</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am checking a range of IP addresses and would like to manipulate the second octet once the third octet has reached 254.&lt;BR /&gt;&lt;BR /&gt;here is what I have so far:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;IP1=0&lt;BR /&gt;IP2=10&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while [ $IP1 -lt 255 ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;IP1=$((IP1+1))&lt;BR /&gt;&lt;BR /&gt;        for NET in 68 200 201 202&lt;BR /&gt;        do&lt;BR /&gt;&lt;BR /&gt;                ping -w 1 -c 1 10.$IP2.$IP1.$NET&lt;BR /&gt;&lt;BR /&gt;                        if [[ $? -ne 0 ]] ; then&lt;BR /&gt;&lt;BR /&gt;                                echo "ERROR: IP 10.$IP2.$IP1.$NET cannot be connected" &amp;gt; netfile.error&lt;BR /&gt;                        else&lt;BR /&gt;                                echo "OK: IP 10.$IP2.$IP1.$NET can be connected" &amp;gt; netfile.ok&lt;BR /&gt;                        fi&lt;BR /&gt;        done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;once all 10.10.254.x have been ping'd i then need to check all ranges for &lt;BR /&gt;&lt;BR /&gt;10.11.x.x &lt;BR /&gt;10.12.x.x&lt;BR /&gt;&lt;BR /&gt;how can I use the syntax to add one more range to the second octet?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 14 Aug 2007 07:16:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054338#M94373</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-08-14T07:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054339#M94374</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;-w is not an option for ping under HPUX.&lt;BR /&gt;Can you try without this option</description>
      <pubDate>Tue, 14 Aug 2007 08:16:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054339#M94374</guid>
      <dc:creator>Luk Vandenbussche</dc:creator>
      <dc:date>2007-08-14T08:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054340#M94375</link>
      <description>&lt;!--!*#--&gt;Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Simply add another (outer) loop.  For example:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -i IP1=0&lt;BR /&gt;&lt;BR /&gt;for IP2 in 10 11 12&lt;BR /&gt;do&lt;BR /&gt;  IP1=0                                                                         &lt;BR /&gt;  while [ ${IP1} -lt 255 ]&lt;BR /&gt;  do&lt;BR /&gt;    IP1=$((IP1+1))&lt;BR /&gt;    for NET in 68 200 201 202&lt;BR /&gt;    do&lt;BR /&gt;      ping -w 1 -c 1 10.${IP2}.${IP1}.${NET}&lt;BR /&gt;      if [[ $? -ne 0 ]] ; then&lt;BR /&gt;        echo "ERROR: IP 10.${IP2}.${IP1}.${NET} cannot be connected" \&lt;BR /&gt;            &amp;gt; netfile.error&lt;BR /&gt;      else&lt;BR /&gt;        echo "OK: IP 10.${IP2}.${IP1}.${NET} can be connected" &amp;gt; netfile.ok&lt;BR /&gt;      fi&lt;BR /&gt;    done&lt;BR /&gt;  done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...Notice, too, that I changed your variable declaration to a typeset integer for faster arithmetic and surrounded your variables with curly braces --- a good habit to learn to avoid ambiguity in parameter substitution.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 14 Aug 2007 08:19:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054340#M94375</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-08-14T08:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054341#M94376</link>
      <description>sorry I should have mentioned that I am running this on an AIX system therefor -w 1 is the ping timeout.&lt;BR /&gt;&lt;BR /&gt;I have actually worked out a solution however could do with a more advanced script:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;IP1=0&lt;BR /&gt;IP2=10&lt;BR /&gt;&amp;gt;netfile.error&lt;BR /&gt;&amp;gt;netfile.ok&lt;BR /&gt;&lt;BR /&gt;while [[ $IP1 -lt 255 &amp;amp;&amp;amp; $IP2 -lt 13 ]]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;        if [[ $IP1 -lt 254 ]] ; then&lt;BR /&gt;&lt;BR /&gt;                IP1=$IP1&lt;BR /&gt;&lt;BR /&gt;        else&lt;BR /&gt;                IP1=0&lt;BR /&gt;                IP2=$((IP2+1))&lt;BR /&gt;&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;IP1=$((IP1+1))&lt;BR /&gt;&lt;BR /&gt;        for NET in 68 200 201 202&lt;BR /&gt;        do&lt;BR /&gt;&lt;BR /&gt;                ping -w 1 -c 1 10.$IP2.$IP1.$NET&lt;BR /&gt;&lt;BR /&gt;                        if [[ $? -ne 0 ]] ; then&lt;BR /&gt;&lt;BR /&gt;                                echo "ERROR: IP 10.$IP2.$IP1.$NET cannot be connected" &amp;gt;&amp;gt; netfile.error&lt;BR /&gt;                        else&lt;BR /&gt;                                echo "OK: IP 10.$IP2.$IP1.$NET can be connected" &amp;gt;&amp;gt; netfile.ok&lt;BR /&gt;                        fi&lt;BR /&gt;        done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;not use if this is working correctly as it is running through now.&lt;BR /&gt;&lt;BR /&gt;What I would like is a solution that allows me to check all IP's on a range of networks and each octet being incremented:&lt;BR /&gt;&lt;BR /&gt;check &lt;BR /&gt;&lt;BR /&gt;10.1.1.2&lt;BR /&gt;10.1.1.3&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;then check&lt;BR /&gt;&lt;BR /&gt;10.1.2.1&lt;BR /&gt;10.1.2.2&lt;BR /&gt;10.1.2.3&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;then check&lt;BR /&gt;&lt;BR /&gt;10.2.1.1&lt;BR /&gt;10.2.1.2&lt;BR /&gt;10.2.1.3&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;how can I easily increment each octet?&lt;BR /&gt;&lt;BR /&gt;many thanks in advance&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Aug 2007 08:28:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054341#M94376</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-08-14T08:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054342#M94377</link>
      <description>Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; What I would like is a solution that allows me to check all IP's on a range of networks and each octet being incremented:&lt;BR /&gt;&lt;BR /&gt;Again, nested loops to increment each octet is all that you need.  Simply be sure to re-initialize the low-order octets everytime you increment a higher-order one.  I showed the addition of a 'for' loop only because it appeared that you wanted only a few ranges.  Use multiple 'while' loops.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 14 Aug 2007 08:33:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054342#M94377</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-08-14T08:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: while loop help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054343#M94378</link>
      <description>How about a completely different approach that will get them all (at least for a subnet) in one shot? Rather than ping each IP address, ping the broadcast address and see who responds.</description>
      <pubDate>Tue, 14 Aug 2007 12:03:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/while-loop-help/m-p/4054343#M94378</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-08-14T12:03:45Z</dc:date>
    </item>
  </channel>
</rss>

