<?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: For loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982918#M294584</link>
    <description>&amp;gt;doesn't seem to recognize typeset command&lt;BR /&gt;&lt;BR /&gt;A real shell recognizes typeset.  I thought bash was ksh/sh like?  Perhaps you should use the real shell in your scripts.&lt;BR /&gt;&lt;BR /&gt;You can replace typeset by just:&lt;BR /&gt;index=0</description>
    <pubDate>Tue, 17 Apr 2007 07:42:11 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-04-17T07:42:11Z</dc:date>
    <item>
      <title>For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982915#M294581</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;Can anyone help me with a case how to ping x.x.x.0 to x.x.x.255 and put the ones which are alive to a text file ??&lt;BR /&gt;&lt;BR /&gt;Thanks in advance...</description>
      <pubDate>Tue, 17 Apr 2007 06:56:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982915#M294581</guid>
      <dc:creator>Zan_1</dc:creator>
      <dc:date>2007-04-17T06:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982916#M294582</link>
      <description>&lt;!--!*#--&gt;You need a while loop:&lt;BR /&gt;typeset -i index=0&lt;BR /&gt;while [ $index -le 255 ]; do&lt;BR /&gt;   ping xxx.$index&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      echo xxx.$index &amp;gt;&amp;gt; alive.file&lt;BR /&gt;   fi&lt;BR /&gt;   (( index=index + 1 ))&lt;BR /&gt;done</description>
      <pubDate>Tue, 17 Apr 2007 07:13:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982916#M294582</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-04-17T07:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982917#M294583</link>
      <description>hmm.. doesn't seem to recognize typeset command...&lt;BR /&gt;&lt;BR /&gt;bash-3.00# ./ping.sh&lt;BR /&gt;./ping.sh: typeset: not found&lt;BR /&gt;./ping.sh: test: argument expected&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 07:34:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982917#M294583</guid>
      <dc:creator>Zan_1</dc:creator>
      <dc:date>2007-04-17T07:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982918#M294584</link>
      <description>&amp;gt;doesn't seem to recognize typeset command&lt;BR /&gt;&lt;BR /&gt;A real shell recognizes typeset.  I thought bash was ksh/sh like?  Perhaps you should use the real shell in your scripts.&lt;BR /&gt;&lt;BR /&gt;You can replace typeset by just:&lt;BR /&gt;index=0</description>
      <pubDate>Tue, 17 Apr 2007 07:42:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982918#M294584</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-04-17T07:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982919#M294585</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Bash uses 'declare' instead of 'typeset'.&lt;BR /&gt;&lt;BR /&gt;You probably also want to amend your ping in Dennis' script to:&lt;BR /&gt;&lt;BR /&gt;# ping xxx.$index -n 1&lt;BR /&gt;&lt;BR /&gt;...such that only one ping is sent for each address.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 07:42:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982919#M294585</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-17T07:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982920#M294586</link>
      <description>Nevertheless, Bash should understand a typeset declaration&lt;BR /&gt;&lt;BR /&gt;$ echo $0&lt;BR /&gt;-bash&lt;BR /&gt;$ echo ${BASH_VERSINFO[*]}&lt;BR /&gt;3 00 15 1 release i386-redhat-linux-gnu&lt;BR /&gt;$ typeset -i some_int=42&lt;BR /&gt;$ declare -i|grep some&lt;BR /&gt;declare -i some_int="42"&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 09:54:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982920#M294586</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-04-17T09:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982921#M294587</link>
      <description>For a flexible, scriptable ping usage, You might want to consider the PERL module Net::Ping&lt;BR /&gt;&lt;BR /&gt;Basic docu:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://perldoc.perl.org/Net/Ping.html" target="_blank"&gt;http://perldoc.perl.org/Net/Ping.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Extended example usage in attachment to Clay's note in:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=22018" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=22018&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Simple example for your case:&lt;BR /&gt;&lt;BR /&gt;--------------------- ping_network.pl -----&lt;BR /&gt;use strict;&lt;BR /&gt;use Net::Ping;&lt;BR /&gt;my $timeout = 2;&lt;BR /&gt;my $network = shift;&lt;BR /&gt;($network =~ !/\d+\.\d+\.\d+/) or die "Please provide nextwork adrress as xx.xx.xx";&lt;BR /&gt;my $p = Net::Ping-&amp;gt;new('tcp');&lt;BR /&gt;foreach (0..255) {&lt;BR /&gt;    my $host = "$network.$_";&lt;BR /&gt;    my $stat = $p-&amp;gt;ping($host,$timeout);&lt;BR /&gt;#    printf "%s %d %s\n", $host, $stat, $stat? 'up' : 'down';&lt;BR /&gt;    print "$host\n" if $stat;&lt;BR /&gt;    }&lt;BR /&gt;$p-&amp;gt;close();&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;BR /&gt;# perl ping_network.pl 192.168.1 &amp;gt; up.txt&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein van den Heuvel (at gmail dot com)&lt;BR /&gt;HvdH Performance Consulting&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Apr 2007 13:43:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982921#M294587</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-04-17T13:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: For loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982922#M294588</link>
      <description>For scripting ping checkers I also prefer the Net::Ping module that Hein has introduced.&lt;BR /&gt;One thing noteworthy about it is&lt;BR /&gt;that it can be employed more universal than an ordinary ping command.&lt;BR /&gt;For one (as Hein demonstrated), you can emit ordinary TCP packets and thus don't require root privileges or a setuid script unlike with ICMP packets.&lt;BR /&gt;Even better yet, it allows you to virtually ping every service by selection of the destination port.&lt;BR /&gt;Albeit, if you are an OO purist you probably would frown on the Net::Ping module's bad interface that it doesn't offer a proper accessor for setting the port but rather requires the user to mangle with the Net::Ping object like so:&lt;BR /&gt;&lt;BR /&gt;use Net::Ping;&lt;BR /&gt;my $p = Net::Ping-&amp;gt;new('tcp');&lt;BR /&gt;# setting to SSH's registered port&lt;BR /&gt;$p-&amp;gt;{port_num} = getservbyname('ssh', 'tcp');&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Apr 2007 02:35:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/for-loop/m-p/3982922#M294588</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-04-18T02:35:25Z</dc:date>
    </item>
  </channel>
</rss>

