<?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: awk script using system COMMAND in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821191#M720902</link>
    <description>Hi Glenn:&lt;BR /&gt;&lt;BR /&gt;You can pass a variable into a 'awk' script thusly:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;typeset THEFILE=$1&lt;BR /&gt;awk -v THEFILE="$THEFILE"' &lt;BR /&gt;{ if ($2~/455/) { &lt;BR /&gt;if (substr($4,17,6)=="abcdef") { &lt;BR /&gt;COMMAND=("grep -q " substr($4,1,4) " "THEFILE)&lt;BR /&gt;if (system(COMMAND)) &lt;BR /&gt;{print $0 "XXbb" &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0 "XXYY" &lt;BR /&gt;} &lt;BR /&gt;close(COMMAND) &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0"bbbb" &lt;BR /&gt;} &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0 &lt;BR /&gt;} &lt;BR /&gt;} ' /tmp/myinput &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 08 Oct 2002 19:18:36 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-10-08T19:18:36Z</dc:date>
    <item>
      <title>awk script using system COMMAND</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821189#M720900</link>
      <description>I have an awk script that was reccommened on 10/7/02.  See the my previous entry, for details.&lt;BR /&gt;Here is the line that I'm having a problem with.&lt;BR /&gt;&lt;BR /&gt;COMMAND=("grep -q " substr($0,53,4) "  /tmp/reffile")&lt;BR /&gt;&lt;BR /&gt;The above line works, but it needs to have a variable for the file name, based on SITECODE.  I tried  $REFFILE, but it didn't work.  This script will use different DATAFILE files, and REFFILE files, based on SITECODE. &lt;BR /&gt;See the attachment for the exact coding.&lt;BR /&gt;The attachment has additional comments.</description>
      <pubDate>Tue, 08 Oct 2002 18:42:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821189#M720900</guid>
      <dc:creator>Glenn Morton_1</dc:creator>
      <dc:date>2002-10-08T18:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: awk script using system COMMAND</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821190#M720901</link>
      <description>Glenn,&lt;BR /&gt;&lt;BR /&gt;If you checked that thread, I posted one script purely in Shell that can be easily modified to fit your purposes. It will take care of things like this.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Tue, 08 Oct 2002 18:54:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821190#M720901</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-10-08T18:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: awk script using system COMMAND</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821191#M720902</link>
      <description>Hi Glenn:&lt;BR /&gt;&lt;BR /&gt;You can pass a variable into a 'awk' script thusly:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;typeset THEFILE=$1&lt;BR /&gt;awk -v THEFILE="$THEFILE"' &lt;BR /&gt;{ if ($2~/455/) { &lt;BR /&gt;if (substr($4,17,6)=="abcdef") { &lt;BR /&gt;COMMAND=("grep -q " substr($4,1,4) " "THEFILE)&lt;BR /&gt;if (system(COMMAND)) &lt;BR /&gt;{print $0 "XXbb" &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0 "XXYY" &lt;BR /&gt;} &lt;BR /&gt;close(COMMAND) &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0"bbbb" &lt;BR /&gt;} &lt;BR /&gt;} &lt;BR /&gt;else &lt;BR /&gt;{print $0 &lt;BR /&gt;} &lt;BR /&gt;} ' /tmp/myinput &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Oct 2002 19:18:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821191#M720902</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T19:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: awk script using system COMMAND</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821192#M720903</link>
      <description>You might try this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;FILE=$1&lt;BR /&gt;VAR=$2&lt;BR /&gt;&lt;BR /&gt;echo "debug: file=$FILE var=$VAR"&lt;BR /&gt;&lt;BR /&gt;echo "" | awk '{&lt;BR /&gt;printf "this is the '"${FILE}"' file.\n"&lt;BR /&gt;printf "and this the '"${VAR}"' variable\n"&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;=======================&lt;BR /&gt;&amp;gt; ./pass_vars BLAH BLEH&lt;BR /&gt;debug: file=BLAH var=BLEH&lt;BR /&gt;this is the BLAH file.&lt;BR /&gt;and this the BLEH variable&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ./pass_vars "BLAH BLAH" "BLEH BLEH"&lt;BR /&gt;debug: file=BLAH BLAH var=BLEH BLEH&lt;BR /&gt;this is the BLAH BLAH file.&lt;BR /&gt;and this the BLEH BLEH variable&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 20:13:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821192#M720903</guid>
      <dc:creator>wyan lowe</dc:creator>
      <dc:date>2002-10-08T20:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: awk script using system COMMAND</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821193#M720904</link>
      <description>Hi (again) Glenn:&lt;BR /&gt;&lt;BR /&gt;...sorry, priority interrupt.   In the case you have shown, I'd simply create a procedure (function) to which you pass the value of the input file (INPFILE) and the reference file (REFFILE).  This will allow you to call the 'awk' code with variable arguments.  Mind you, this is but one way you can implement this.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh                                  &lt;BR /&gt;typeset INPFILE=$1&lt;BR /&gt;typeset REFFILE=$2&lt;BR /&gt;#&lt;BR /&gt;function filter&lt;BR /&gt;{&lt;BR /&gt;awk -v REFFILE=$REFFILE '&lt;BR /&gt;  { if ($2~/455/) {&lt;BR /&gt;      if (substr($4,17,6)=="abcdef") {&lt;BR /&gt;        COMMAND=("grep -q " substr($4,1,4) " "REFFILE)&lt;BR /&gt;        if (system(COMMAND))&lt;BR /&gt;          {print $0 "XXbb"&lt;BR /&gt;          }&lt;BR /&gt;        else&lt;BR /&gt;          {print $0 "XXYY"&lt;BR /&gt;          }&lt;BR /&gt;        close(COMMAND)&lt;BR /&gt;      }&lt;BR /&gt;    else &lt;BR /&gt;      {print $0"bbbb"&lt;BR /&gt;      }&lt;BR /&gt;  }&lt;BR /&gt;    else&lt;BR /&gt;      {print $0&lt;BR /&gt;      }&lt;BR /&gt;} ' $INPFILE&lt;BR /&gt;} #_endof_filter&lt;BR /&gt;#&lt;BR /&gt;filter $INPFILE $REFFILE&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...since the indentation will be mangled here, I've also attached the above script.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Oct 2002 20:29:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-using-system-command/m-p/2821193#M720904</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T20:29:21Z</dc:date>
    </item>
  </channel>
</rss>

