<?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: about getline in awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982218#M718308</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You need to close the pipe, since awk cannot open more than one at a time:&lt;BR /&gt;&lt;BR /&gt;function ins &lt;BR /&gt;{ &lt;BR /&gt;awk '{ "date +%H:%M:%S" | getline D;close "date +%H:%M:%S";  print D" "$0 }' &lt;BR /&gt;&lt;BR /&gt;return 0 &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;integer I=0 &lt;BR /&gt;while (( I&amp;lt;5 )) &lt;BR /&gt;do &lt;BR /&gt;print $I &lt;BR /&gt;sleep 1 &lt;BR /&gt;&lt;BR /&gt;I=I+1 &lt;BR /&gt;done | ins&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
    <pubDate>Tue, 27 May 2003 08:14:04 GMT</pubDate>
    <dc:creator>Robin Wakefield</dc:creator>
    <dc:date>2003-05-27T08:14:04Z</dc:date>
    <item>
      <title>about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982211#M718301</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I'm trying to insert the string hour:minute:second at the begin of each line of a command output:&lt;BR /&gt;&lt;BR /&gt;function ins&lt;BR /&gt;{&lt;BR /&gt; awk '{ "date +%H:%M:%S" | getline D; print D" "$0 }'&lt;BR /&gt;&lt;BR /&gt; return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;integer I=0&lt;BR /&gt;while (( I&amp;lt;5 ))&lt;BR /&gt;do&lt;BR /&gt;    print $I&lt;BR /&gt;    sleep 1&lt;BR /&gt;&lt;BR /&gt;    I=I+1&lt;BR /&gt;done | ins&lt;BR /&gt;&lt;BR /&gt;but the output is:&lt;BR /&gt;&lt;BR /&gt;10:25:30 0&lt;BR /&gt;10:25:30 1&lt;BR /&gt;10:25:30 2&lt;BR /&gt;10:25:30 3&lt;BR /&gt;10:25:30 4&lt;BR /&gt;&lt;BR /&gt;It looks like the awk line "date +%H:%M%S | getline D" only is executed one time.&lt;BR /&gt;I'm a mess.&lt;BR /&gt;&lt;BR /&gt;what is wrong ?</description>
      <pubDate>Tue, 27 May 2003 07:28:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982211#M718301</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-27T07:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982212#M718302</link>
      <description>Hi,&lt;BR /&gt;i think the line is correct, it is you that execute it only once !&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;integer I=0 &lt;BR /&gt;while (( I&amp;lt;5 )) &lt;BR /&gt;do &lt;BR /&gt;D=$(ins)&lt;BR /&gt;print $I &lt;BR /&gt;sleep 1 &lt;BR /&gt;&lt;BR /&gt;I=I+1 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;So it should be execute each time you run the script, and not only once.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 07:34:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982212#M718302</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-05-27T07:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982213#M718303</link>
      <description>Hi,&lt;BR /&gt;i think the line is correct, it is you that execute it only once !&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;integer I=0 &lt;BR /&gt;while (( I&amp;lt;5 )) &lt;BR /&gt;do &lt;BR /&gt;D=$(ins)&lt;BR /&gt;print $D $I &lt;BR /&gt;sleep 1 &lt;BR /&gt;&lt;BR /&gt;I=I+1 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;So it should be execute each time you run the script, and not only once.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 07:34:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982213#M718303</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-05-27T07:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982214#M718304</link>
      <description>I don't understand your answers.&lt;BR /&gt;&lt;BR /&gt;According to awk man pages, the awk action &lt;BR /&gt;&lt;BR /&gt;{ "date +%H:%M:%S" | getline D; print D" "$0 }&lt;BR /&gt;&lt;BR /&gt;is executed on every input line not on every awk execution, isn't it ?</description>
      <pubDate>Tue, 27 May 2003 07:46:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982214#M718304</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-27T07:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982215#M718305</link>
      <description>on other words... If a input file is 20 lines long, how many times is executed the command:&lt;BR /&gt;&lt;BR /&gt;    date +%H:%M:%S&lt;BR /&gt; ?&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 07:53:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982215#M718305</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-27T07:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982216#M718306</link>
      <description>Hi,&lt;BR /&gt;yes, you are right.&lt;BR /&gt;&lt;BR /&gt;Sorry I made a mistake, It seemed to me your line was&lt;BR /&gt;&lt;BR /&gt;" done &amp;lt; ins "&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 08:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982216#M718306</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-05-27T08:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982217#M718307</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;function ins&lt;BR /&gt;{&lt;BR /&gt;awk '{ "date +%H:%M:%S" | getline D; print D" "$0; close("date +%H:%M:%S") }'&lt;BR /&gt;&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 08:07:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982217#M718307</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-05-27T08:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982218#M718308</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You need to close the pipe, since awk cannot open more than one at a time:&lt;BR /&gt;&lt;BR /&gt;function ins &lt;BR /&gt;{ &lt;BR /&gt;awk '{ "date +%H:%M:%S" | getline D;close "date +%H:%M:%S";  print D" "$0 }' &lt;BR /&gt;&lt;BR /&gt;return 0 &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;integer I=0 &lt;BR /&gt;while (( I&amp;lt;5 )) &lt;BR /&gt;do &lt;BR /&gt;print $I &lt;BR /&gt;sleep 1 &lt;BR /&gt;&lt;BR /&gt;I=I+1 &lt;BR /&gt;done | ins&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Tue, 27 May 2003 08:14:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982218#M718308</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-05-27T08:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982219#M718309</link>
      <description>HI,&lt;BR /&gt;I thank all the others for the answers, today i learnt something new about awk !&lt;BR /&gt;&lt;BR /&gt;Massimo&lt;BR /&gt;</description>
      <pubDate>Tue, 27 May 2003 08:17:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982219#M718309</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-05-27T08:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982220#M718310</link>
      <description>Dietmar, your suggestion produces no change in the output.&lt;BR /&gt;&lt;BR /&gt;I also ran the same script on a Solaris 8 system (/usr/xpg4/bin/awk is used instead of SunOs awk). The output is:&lt;BR /&gt;&lt;BR /&gt;10:21:54 0&lt;BR /&gt; 1&lt;BR /&gt; 2&lt;BR /&gt; 3&lt;BR /&gt; 4&lt;BR /&gt; 5&lt;BR /&gt; 6&lt;BR /&gt; 7&lt;BR /&gt; 8&lt;BR /&gt; 9&lt;BR /&gt;&lt;BR /&gt;I suspect 'date' is executed just one time.</description>
      <pubDate>Tue, 27 May 2003 08:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982220#M718310</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-27T08:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982221#M718311</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I had almost the same answer as 2 previous, and it works for me ...&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;&lt;BR /&gt;hp:/tmp&amp;gt; cat a&lt;BR /&gt;function ins&lt;BR /&gt;{&lt;BR /&gt;awk 'BEGIN {A= "date +%H:%M:%S"} {A | getline D ; print D" "$0 ; close(A) }'&lt;BR /&gt;&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;integer I=0&lt;BR /&gt;while (( I&amp;lt;5 ))&lt;BR /&gt;do&lt;BR /&gt;print $I&lt;BR /&gt;sleep 1&lt;BR /&gt;&lt;BR /&gt;I=I+1&lt;BR /&gt;done | ins&lt;BR /&gt;hp:/tmp&amp;gt; sh a&lt;BR /&gt;11:37:19 0&lt;BR /&gt;11:37:20 1&lt;BR /&gt;11:37:21 2&lt;BR /&gt;11:37:22 3&lt;BR /&gt;11:37:23 4&lt;BR /&gt;hp:/tmp&amp;gt;</description>
      <pubDate>Tue, 27 May 2003 08:38:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982221#M718311</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-05-27T08:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982222#M718312</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;My version works with nawk, you'll need brackets on the close statement with "standard" awk.&lt;BR /&gt;&lt;BR /&gt;I tried Dietmar's on my Solaris 8 system with /usr/xpg4/bin/awk, and it worked fine.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ uname -a   &lt;BR /&gt;SunOS schi0039pmh 5.8 Generic_108528-14 sun4u sparc SUNW,Ultra-80&lt;BR /&gt;$ cat script&lt;BR /&gt;function ins &lt;BR /&gt;{ &lt;BR /&gt;/usr/xpg4/bin/awk '{ "date +%H:%M:%S" | getline D;print D" "$0 ;close("date +%H:%M:%S")}' &lt;BR /&gt;&lt;BR /&gt;return 0 &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;integer I=0 &lt;BR /&gt;while (( I&amp;lt;5 )) &lt;BR /&gt;do &lt;BR /&gt;print $I &lt;BR /&gt;sleep 1 &lt;BR /&gt;&lt;BR /&gt;I=I+1 &lt;BR /&gt;done | ins &lt;BR /&gt;&lt;BR /&gt;$ script&lt;BR /&gt;04:46:50 0&lt;BR /&gt;04:46:51 1&lt;BR /&gt;04:46:52 2&lt;BR /&gt;04:46:53 3&lt;BR /&gt;04:46:54 4&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Tue, 27 May 2003 08:47:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982222#M718312</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-05-27T08:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982223#M718313</link>
      <description>Sorry, I mistyped the argument of 'close' sentence in my script. Then the pipe wasn't closed.&lt;BR /&gt;&lt;BR /&gt;Now it works fine.&lt;BR /&gt;&lt;BR /&gt;Thanx everybody.</description>
      <pubDate>Tue, 27 May 2003 09:00:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982223#M718313</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-27T09:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: about getline in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982224#M718314</link>
      <description>You need to take care that the close() gets exactly the pipe's command string as argument! So Jean-Louis' approach using a variable seems to be the more elegant one.&lt;BR /&gt;&lt;BR /&gt;Best regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 27 May 2003 09:01:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/about-getline-in-awk/m-p/2982224#M718314</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-05-27T09:01:31Z</dc:date>
    </item>
  </channel>
</rss>

