<?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: how to substitute variable in awk. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884961#M704469</link>
    <description>&lt;BR /&gt;This is how we can address variable "a" in awk.&lt;BR /&gt;awk '$1 == ENVIRON["a"] &lt;BR /&gt;{  print $0 } ' /etc/hosts</description>
    <pubDate>Thu, 10 Feb 2005 06:53:07 GMT</pubDate>
    <dc:creator>ankurp</dc:creator>
    <dc:date>2005-02-10T06:53:07Z</dc:date>
    <item>
      <title>how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884956#M704464</link>
      <description>Hi friends,&lt;BR /&gt;&lt;BR /&gt;I want check if all my servers are up by this script, can any one help me with 2 issues&lt;BR /&gt;&lt;BR /&gt;1) How to insert variable in awk (awk '$1 == "$a" {  print $0 } ' /etc/hosts )&lt;BR /&gt;&lt;BR /&gt;2) How to set timeout for ping ?&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;for a in &lt;BR /&gt;` sed -n '/202/p' /usr/scripts/ping_server.sh | awk ' { print $1 } '`&lt;BR /&gt;do&lt;BR /&gt;echo pinging  $a&lt;BR /&gt;&lt;BR /&gt;flag=`ping $a -n 3`&lt;BR /&gt;echo $flag | grep -i '0% packet loss'&lt;BR /&gt;echo $?&lt;BR /&gt;&lt;BR /&gt;if [ "$?" -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;h=`awk '$1 == "$a" {  print $0 } ' /etc/hosts `&lt;BR /&gt;echo " $h Host Alive "&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Waitn  for u r responce.&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Ankur</description>
      <pubDate>Thu, 10 Feb 2005 04:14:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884956#M704464</guid>
      <dc:creator>ankurp</dc:creator>
      <dc:date>2005-02-10T04:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884957#M704465</link>
      <description>&lt;BR /&gt;man awk tells you to use -v parameter&lt;BR /&gt;&lt;BR /&gt;awk -v myvar=$a '{print myvar}' filename&lt;BR /&gt;&lt;BR /&gt;But&lt;BR /&gt;A far better method to check to see if your hosts are up is to use ruptime.&lt;BR /&gt;&lt;BR /&gt;vi /etc/rc.config.d/netdaemons&lt;BR /&gt;set RWHOD=1&lt;BR /&gt;start rwhod&lt;BR /&gt;&lt;BR /&gt;then, define host equivalence for your machines.&lt;BR /&gt;$ ruptime&lt;BR /&gt;&lt;BR /&gt;It will run uptime on all your remote systems and list them all at once.  It also shows the load on each machine.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Feb 2005 04:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884957#M704465</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2005-02-10T04:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884958#M704466</link>
      <description>try   awk '$1 == "'"$a"'" { print $0 } ' /etc/hosts `</description>
      <pubDate>Thu, 10 Feb 2005 04:50:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884958#M704466</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2005-02-10T04:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884959#M704467</link>
      <description>You can also use this:&lt;BR /&gt;&lt;BR /&gt;export A=2&lt;BR /&gt;awk '{p=ENVIRON["A"];print p}'&lt;BR /&gt;&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Feb 2005 04:51:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884959#M704467</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2005-02-10T04:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884960#M704468</link>
      <description>thanks laurant and steve for ur quick responces. &lt;BR /&gt;Im happy.&lt;BR /&gt;For laurant : awk: Field $() is not correct.&lt;BR /&gt;The input line number is 1. The file is /etc/hosts.&lt;BR /&gt; The source line number is 1.&lt;BR /&gt;&lt;BR /&gt;Steve's thing worked , but had to some tweakin.&lt;BR /&gt; &lt;BR /&gt;Regards&lt;BR /&gt;Ankur&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Feb 2005 06:49:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884960#M704468</guid>
      <dc:creator>ankurp</dc:creator>
      <dc:date>2005-02-10T06:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to substitute variable in awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884961#M704469</link>
      <description>&lt;BR /&gt;This is how we can address variable "a" in awk.&lt;BR /&gt;awk '$1 == ENVIRON["a"] &lt;BR /&gt;{  print $0 } ' /etc/hosts</description>
      <pubDate>Thu, 10 Feb 2005 06:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-substitute-variable-in-awk/m-p/4884961#M704469</guid>
      <dc:creator>ankurp</dc:creator>
      <dc:date>2005-02-10T06:53:07Z</dc:date>
    </item>
  </channel>
</rss>

