<?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: passing script variable in awk . in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461748#M662222</link>
    <description>Hi James,&lt;BR /&gt;Thanks for reply.&lt;BR /&gt;&lt;BR /&gt;I inserted a space in those brackets .&lt;BR /&gt;&lt;BR /&gt;NB_BANNER=$(echo $BANNER | sed -e s/\./11/g' -e 's| |00|g')&lt;BR /&gt;&lt;BR /&gt;cat "/etc/dt/config/C/Xresources" | awk -v VAR="${NB_BANNER}" 'BEGIN{ FS=":" ;OFS=":" };&lt;BR /&gt;{&lt;BR /&gt;if($1~"^[ ]*Dtlogin.*greeting\.persLabelString")&lt;BR /&gt;{ sub("00"," ",VAR);&lt;BR /&gt;sub("11"," ",VAR);&lt;BR /&gt;$2=" "VAR;&lt;BR /&gt;}&lt;BR /&gt;{print;}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;but it is giving same result , same error message&lt;BR /&gt;&lt;BR /&gt;after replacing correctors , the banner string looks like this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Authorized00users00only1100All00activity00may00be00monitored00and00reported11&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
    <pubDate>Fri, 17 Jul 2009 10:56:02 GMT</pubDate>
    <dc:creator>Gunwant</dc:creator>
    <dc:date>2009-07-17T10:56:02Z</dc:date>
    <item>
      <title>passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461744#M662218</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I want to pass a script variable in to the awk command. The script variable is a message string having blank spaces.&lt;BR /&gt;$BANNER="Authorized users only. All activity may be monitored and reported."&lt;BR /&gt;&lt;BR /&gt;The awk command is &lt;BR /&gt;&lt;BR /&gt;  ND_BANNER=`echo $BANNER |sed 's/\./\+/g'`&lt;BR /&gt;  NB_BANNER=`echo $ND_BANNER |sed 's| |_|g'`&lt;BR /&gt;&lt;BR /&gt;cat $FILE | awk VAR="${NB_BANNER}" 'BEGIN{ FS=":" ;OFS=":" };{ if($1~"^[ ]*Dtlogin.*greeting\.persLabelString"){ sub("+"," ",VAR); $2=" "VAR;}{print;}}'&lt;BR /&gt;&lt;BR /&gt;I am replacing blank space with "_" sign  and "." with "+".&lt;BR /&gt;&lt;BR /&gt;I am getting following error.&lt;BR /&gt;&lt;BR /&gt; syntax error The source line is 1.&lt;BR /&gt; The error context is&lt;BR /&gt;                 &amp;gt;&amp;gt;&amp;gt; VAR=Authorized_users_only._All_activity_may_be_monitored_and_reported+ &amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt; awk: Quitting&lt;BR /&gt; The source line is 1.&lt;BR /&gt;&lt;BR /&gt;I cannot find out why this is giving error.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Fri, 17 Jul 2009 07:09:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461744#M662218</guid>
      <dc:creator>Gunwant</dc:creator>
      <dc:date>2009-07-17T07:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461745#M662219</link>
      <description>&lt;!--!*#--&gt;I should have looked closer.  Your syntax is wrong, you need -v and quote the "+":&lt;BR /&gt;&lt;BR /&gt;NB_BANNER=$(echo $BANNER | sed -e 's/\./\+/g' -e 's| |_|g')&lt;BR /&gt;&lt;BR /&gt;awk -v VAR="${NB_BANNER}" '&lt;BR /&gt;BEGIN{ FS=":" ; OFS=":" }&lt;BR /&gt;{ if($1~"^[ ]*Dtlogin.*greeting\.persLabelString"){&lt;BR /&gt;   sub("\+", " ", VAR)&lt;BR /&gt;   $2=" " VAR&lt;BR /&gt;}&lt;BR /&gt;{print}&lt;BR /&gt;}' $FILE</description>
      <pubDate>Fri, 17 Jul 2009 09:55:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461745#M662219</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-17T09:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461746#M662220</link>
      <description>Hi Dennis,&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;Sorry , my mistake .&lt;BR /&gt;&lt;BR /&gt;I did changes in the above command&lt;BR /&gt;&lt;BR /&gt; NB_BANNER=$(echo $BANNER | sed -e s/\./11/g' -e 's| |00|g')&lt;BR /&gt;&lt;BR /&gt; cat "/etc/dt/config/C/Xresources" | awk -v VAR="${NB_BANNER}" 'BEGIN{ FS=":" ;OFS=":" };&lt;BR /&gt;{ &lt;BR /&gt;if($1~"^[]*Dtlogin.*greeting\.persLabelString")&lt;BR /&gt;{ sub("00"," ",VAR); &lt;BR /&gt;  sub("11"," ",VAR);&lt;BR /&gt; $2=" "VAR;&lt;BR /&gt;}&lt;BR /&gt;{print;}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;I just used 00 for space and 11 for ".".&lt;BR /&gt;It gives following error message&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk: There is a regular expression error.&lt;BR /&gt;        ?, *, or + not preceded by valid regular expression&lt;BR /&gt; The source line number is 1.&lt;BR /&gt; The error context is&lt;BR /&gt;                BEGIN{ FS=":" ;OFS=":" };{ if($1~"^[ ]*Dtlogin.*greeting\.persLabelString"){ print VAR ;sub("+"," &amp;gt;&amp;gt;&amp;gt;  ",VAR) &amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jul 2009 10:12:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461746#M662220</guid>
      <dc:creator>Gunwant</dc:creator>
      <dc:date>2009-07-17T10:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461747#M662221</link>
      <description>Hi Gunwant:&lt;BR /&gt;&lt;BR /&gt;You collapsed the space within '[ ]'.  Instead of:&lt;BR /&gt;&lt;BR /&gt;if($1~"^[]*Dtlogin.*greeting\.persLabelString")&lt;BR /&gt;&lt;BR /&gt;...you should have:&lt;BR /&gt;&lt;BR /&gt;if($1~"^[ ]*Dtlogin.*greeting\.persLabelString")&lt;BR /&gt;&lt;BR /&gt;The use of '[ ]' makes a space character more clearly distinguishable in 'awk'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jul 2009 10:39:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461747#M662221</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-17T10:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461748#M662222</link>
      <description>Hi James,&lt;BR /&gt;Thanks for reply.&lt;BR /&gt;&lt;BR /&gt;I inserted a space in those brackets .&lt;BR /&gt;&lt;BR /&gt;NB_BANNER=$(echo $BANNER | sed -e s/\./11/g' -e 's| |00|g')&lt;BR /&gt;&lt;BR /&gt;cat "/etc/dt/config/C/Xresources" | awk -v VAR="${NB_BANNER}" 'BEGIN{ FS=":" ;OFS=":" };&lt;BR /&gt;{&lt;BR /&gt;if($1~"^[ ]*Dtlogin.*greeting\.persLabelString")&lt;BR /&gt;{ sub("00"," ",VAR);&lt;BR /&gt;sub("11"," ",VAR);&lt;BR /&gt;$2=" "VAR;&lt;BR /&gt;}&lt;BR /&gt;{print;}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;but it is giving same result , same error message&lt;BR /&gt;&lt;BR /&gt;after replacing correctors , the banner string looks like this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Authorized00users00only1100All00activity00may00be00monitored00and00reported11&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jul 2009 10:56:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461748#M662222</guid>
      <dc:creator>Gunwant</dc:creator>
      <dc:date>2009-07-17T10:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461749#M662223</link>
      <description>&amp;gt;It gives following error message:&lt;BR /&gt;awk: There is a regular expression error.&lt;BR /&gt;?, *, or + not preceded by valid regular expression&lt;BR /&gt;&lt;BR /&gt;If you look at my changes and my reply you'll see I already told you I fixed it.&lt;BR /&gt;awk takes ERE and you need to quote the naked "+".&lt;BR /&gt;If you format ALL of your awk programs with separate lines like I do, it points right at it.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jul 2009 11:33:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461749#M662223</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-17T11:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: passing script variable in awk .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461750#M662224</link>
      <description>Thanks , i got it</description>
      <pubDate>Fri, 17 Jul 2009 15:00:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-script-variable-in-awk/m-p/4461750#M662224</guid>
      <dc:creator>Gunwant</dc:creator>
      <dc:date>2009-07-17T15:00:15Z</dc:date>
    </item>
  </channel>
</rss>

