<?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: script help: awk input string parsing in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649176#M879810</link>
    <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;Do you mean this (?):&lt;BR /&gt;&lt;BR /&gt;# echo "hello"|awk -v WHO=bill '{print $0,WHO}'&lt;BR /&gt;&lt;BR /&gt;...or, alternately:&lt;BR /&gt;&lt;BR /&gt;# echo "hello"|awk '{print $0,WHO}' WHO=bill&lt;BR /&gt;&lt;BR /&gt;...of course, the literal string "bill" could be a $VARIABLE from the shell...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 21 Jan 2002 18:27:15 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-01-21T18:27:15Z</dc:date>
    <item>
      <title>script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649169#M879803</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;got this script from here:&lt;BR /&gt;&lt;BR /&gt;RTN=`echo $1 | awk '&lt;BR /&gt;{&lt;BR /&gt; stmp="\""&lt;BR /&gt;stmp=sprintf("%s%s%sx%s",stmp,"\\\\","\\\\","81")&lt;BR /&gt; tmp=$1&lt;BR /&gt; olenoftmp=length(tmp)&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {tmp = 0 tmp}&lt;BR /&gt; lenoftmp=length(tmp) / 2&lt;BR /&gt;for (i = 1; i &amp;lt; lenoftmp+1 ; i++) {&lt;BR /&gt; stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,&lt;BR /&gt;(i*2)-1,1))&lt;BR /&gt;}&lt;BR /&gt;stmp = sprintf("%s%s%sxF7\",%d",stmp,"\\\\","\\\\",olenoftmp+1)&lt;BR /&gt; printf stmp&lt;BR /&gt;}&lt;BR /&gt;'`&lt;BR /&gt;&lt;BR /&gt;echo RTN&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That produces this o/p:&lt;BR /&gt;&lt;BR /&gt;./file 1234567&lt;BR /&gt;&lt;BR /&gt; "\x81\x10\x32\x54\x76\xF7",8&lt;BR /&gt;&lt;BR /&gt;but I need it in fact to do this:&lt;BR /&gt;&lt;BR /&gt; "\x81\x10\x32\x54\x76\xF7",6&lt;BR /&gt;&lt;BR /&gt;where the last 6 is the number of \x 's&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;the 81 is because there is an odd number of input digits.&lt;BR /&gt;&lt;BR /&gt;If the number of digits is even&lt;BR /&gt;&lt;BR /&gt;"\x10\x21\x43\x65\x87\xFF",6&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;any help appreciated..&lt;BR /&gt;Thanks,&lt;BR /&gt;Bill&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Jan 2002 10:23:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649169#M879803</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-01-21T10:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649170#M879804</link>
      <description>Halfway there..&lt;BR /&gt;&lt;BR /&gt;RTN=`echo $1 | awk '&lt;BR /&gt;{&lt;BR /&gt;stmp="\""&lt;BR /&gt;stmp=sprintf("%s%s%sx%s",stmp,"\\\\","\\\\","81")&lt;BR /&gt;tmp=$1&lt;BR /&gt;olenoftmp=length(tmp)&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {tmp = 0 tmp}&lt;BR /&gt;lenoftmp=length(tmp) / 2&lt;BR /&gt;for (i = 1; i &amp;lt; lenoftmp+1 ; i++) {&lt;BR /&gt;stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,&lt;BR /&gt;(i*2)-1,1))&lt;BR /&gt;numb=sprintf("%s",i)&lt;BR /&gt;}&lt;BR /&gt;stmp = sprintf("%s%s%sxF7\",%d",stmp,"\\\\","\\\\",i+1)&lt;BR /&gt;printf stmp&lt;BR /&gt;}&lt;BR /&gt;'`&lt;BR /&gt;&lt;BR /&gt;will produce (12345)&lt;BR /&gt;"\x81\x21\x43\x65\xF7",5&lt;BR /&gt;&lt;BR /&gt;and (123456)&lt;BR /&gt;"\x81\x21\x43\x65\x87\xF7",6&lt;BR /&gt;&lt;BR /&gt;however, in the first case,&lt;BR /&gt;the F7 should be &lt;BR /&gt;"\x81\x21\x43\xF5",4&lt;BR /&gt;&lt;BR /&gt;and in the second&lt;BR /&gt;"\x10\x21\x43\x65\xFF",5&lt;BR /&gt;&lt;BR /&gt;ie.. the F7 and first field are wrong.. but at least the last digit is right!&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Mon, 21 Jan 2002 12:33:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649170#M879804</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-01-21T12:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649171#M879805</link>
      <description>This looks okay for the moment!:&lt;BR /&gt;&lt;BR /&gt;God, I hates awk!&lt;BR /&gt;&lt;BR /&gt;(Does it really mean awkward?)&lt;BR /&gt;&lt;BR /&gt;RET = `echo $1 | awk '&lt;BR /&gt;{&lt;BR /&gt;stmp="\""&lt;BR /&gt;tmp=$1&lt;BR /&gt;olenoftmp=length(tmp)&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {&lt;BR /&gt;stmp = sprintf("%s%s%sx81",stmp,"\\\\","\\\\")&lt;BR /&gt;} else {&lt;BR /&gt;stmp = sprintf("%s%s%sx10",stmp,"\\\\","\\\\")&lt;BR /&gt;}&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {tmp = tmp F }&lt;BR /&gt;lenoftmp=length(tmp) / 2&lt;BR /&gt;for (i = 1; i &amp;lt; lenoftmp+1 ; i++) {&lt;BR /&gt;stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,&lt;BR /&gt;(i*2)-1,1))&lt;BR /&gt;numb=sprintf("%s",i)&lt;BR /&gt;}&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {&lt;BR /&gt;stmp = sprintf("%sF\", %d",stmp,i)&lt;BR /&gt;} else {&lt;BR /&gt;stmp = sprintf("%s%sxFF\", %d",stmp,"\\\\",i+1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;printf stmp&lt;BR /&gt;}&lt;BR /&gt;'`</description>
      <pubDate>Mon, 21 Jan 2002 13:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649171#M879805</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-01-21T13:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649172#M879806</link>
      <description>RTN=`echo $1 | awk '&lt;BR /&gt;{&lt;BR /&gt;stmp="\""&lt;BR /&gt;##stmp=sprintf("%s%s%sx%s",stmp,"\\\\","\\\\","81")&lt;BR /&gt;tmp=$1&lt;BR /&gt;olenoftmp=length(tmp)&lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) {tmp = "18" tmp "F"} else {tmp = "01" tmp}&lt;BR /&gt;lenoftmp=length(tmp) / 2&lt;BR /&gt;for (i = 1; i &amp;lt; lenoftmp+1 ; i++) {&lt;BR /&gt;stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,&lt;BR /&gt;(i*2)-1,1))&lt;BR /&gt;}&lt;BR /&gt;if ( ( olenoftmp % 2 ) == 0 ) {stmp = sprintf("%s%s%sxFF",stmp,"\\\\","\\\\")}&lt;BR /&gt;stmp = sprintf("%s\",%d",stmp,olenoftmp)&lt;BR /&gt;printf stmp&lt;BR /&gt;}&lt;BR /&gt;'`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 21 Jan 2002 13:21:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649172#M879806</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-01-21T13:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649173#M879807</link>
      <description>Hi Bill,&lt;BR /&gt;&lt;BR /&gt;Well, how about this:&lt;BR /&gt;&lt;BR /&gt;RTN=`echo $1 | awk ' &lt;BR /&gt;{ &lt;BR /&gt;stmp="\"" &lt;BR /&gt;numx=0&lt;BR /&gt;tmp=$1 &lt;BR /&gt;olenoftmp=length(tmp) &lt;BR /&gt;if ( ( olenoftmp % 2 ) != 0 ) { &lt;BR /&gt;tmp = "180" tmp "7F";&lt;BR /&gt;} else { &lt;BR /&gt;tmp = "01" tmp "FF";&lt;BR /&gt;} &lt;BR /&gt;lenoftmp=length(tmp) / 2 &lt;BR /&gt;for (i = 1; i &amp;lt; lenoftmp+1 ; i++) { &lt;BR /&gt;stmp = sprintf("%s%s%sx%s%s",stmp,"\\\\","\\\\",substr(tmp,(i*2),1),substr(tmp,(i*2)-1,1)) &lt;BR /&gt;numx++&lt;BR /&gt;} &lt;BR /&gt;stmp = sprintf("%s\",%d",stmp,numx) &lt;BR /&gt;&lt;BR /&gt;printf stmp &lt;BR /&gt;} &lt;BR /&gt;' `&lt;BR /&gt;echo $RTN&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Notice, I do all the prep work up front, and let the reversing take care of the rest.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Mon, 21 Jan 2002 13:35:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649173#M879807</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-01-21T13:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649174#M879808</link>
      <description>Thanks for that guys...&lt;BR /&gt;&lt;BR /&gt;Is there any way to add a Shell variable amongst all that awk stuff...&lt;BR /&gt;&lt;BR /&gt;ie, bang in a $HELLO in the middle of the awk .. where the HELLO was defined outside the awk... I feel a lot of `'\"$'s coming along ;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Jan 2002 18:14:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649174#M879808</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-01-21T18:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649175#M879809</link>
      <description>Hi Bill,&lt;BR /&gt;&lt;BR /&gt;sure there is ( from "man awk" ):&lt;BR /&gt;&lt;BR /&gt;ARGC   The number of elements in the ARGV array.&lt;BR /&gt;&lt;BR /&gt;ARGV   An array of command line arguments, excluding options and the program argument numbered from zero to ARGC-1.&lt;BR /&gt;&lt;BR /&gt;ENVIRON  Array of environment variables; subscripts arenames.  For example, if environment variable V=thing, ENVIRON["V"] produces thing.&lt;BR /&gt;&lt;BR /&gt;So I guess you are looking for that ENVIRON array.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Volker&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Jan 2002 18:22:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649175#M879809</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2002-01-21T18:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649176#M879810</link>
      <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;Do you mean this (?):&lt;BR /&gt;&lt;BR /&gt;# echo "hello"|awk -v WHO=bill '{print $0,WHO}'&lt;BR /&gt;&lt;BR /&gt;...or, alternately:&lt;BR /&gt;&lt;BR /&gt;# echo "hello"|awk '{print $0,WHO}' WHO=bill&lt;BR /&gt;&lt;BR /&gt;...of course, the literal string "bill" could be a $VARIABLE from the shell...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 21 Jan 2002 18:27:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649176#M879810</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-01-21T18:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: script help: awk input string parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649177#M879811</link>
      <description>Bill,&lt;BR /&gt;&lt;BR /&gt;Maybe it's time to cross the road and learn "perl"??&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl&lt;BR /&gt;#&lt;BR /&gt;    $stmp = "\"";&lt;BR /&gt;    $tmp = $ARGV[0];&lt;BR /&gt;    $olenoftmp = length($tmp);&lt;BR /&gt;    $Ptmp=$tmp;&lt;BR /&gt;    if ( ( $olenoftmp % 2) == 0)&lt;BR /&gt;       { $tmp = '01' . $Ptmp . 'FF'; }&lt;BR /&gt;    else&lt;BR /&gt;       { $tmp = '18' . $Ptmp . 'F'; }&lt;BR /&gt;    $lenoftmp = length($tmp) / 2;&lt;BR /&gt;    for ($i = 0; $i &amp;lt; $lenoftmp ; $i++) {&lt;BR /&gt;        $Ptmp=$stmp;&lt;BR /&gt;        $stmp = sprintf('%s\\x%s%s', $Ptmp,&lt;BR /&gt;           substr($tmp,($i * 2) + 1, 1), substr($tmp, ($i * 2), 1));&lt;BR /&gt;    }&lt;BR /&gt;    $stmp .= "\"," . $olenoftmp;&lt;BR /&gt;    printf("%s\n",$stmp);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 21 Jan 2002 19:30:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-awk-input-string-parsing/m-p/2649177#M879811</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-01-21T19:30:42Z</dc:date>
    </item>
  </channel>
</rss>

