<?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: scripting help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156635#M684142</link>
    <description>OK thanks dennis,&lt;BR /&gt;&lt;BR /&gt;I am looking for&lt;BR /&gt;&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  print "ETCN",ENT,MODE,EN1,EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   print "ETCN",ENT,MODE,EN,BACKUP&lt;BR /&gt;&lt;BR /&gt;so I am looking to print a different output depending on the mode.&lt;BR /&gt;&lt;BR /&gt;is there a way I can assign the variables to an OUTPUT VAR and print that at the end ie:&lt;BR /&gt;&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  OUTPUT = ENT,MODE,EN1,EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   OUTPUT = ENT,MODE,EN,BACKUP&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END{print "ENTH",OUTPUT}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
    <pubDate>Thu, 12 Feb 2009 12:55:14 GMT</pubDate>
    <dc:creator>lawrenzo_1</dc:creator>
    <dc:date>2009-02-12T12:55:14Z</dc:date>
    <item>
      <title>scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156632#M684139</link>
      <description>here is the data I want to format:&lt;BR /&gt;&lt;BR /&gt;lsdev -dev ent10 -attr&lt;BR /&gt;attribute       value          description                                 user_settable&lt;BR /&gt;&lt;BR /&gt;adapter_names   ent3,ent7      EtherChannel Adapters                       True&lt;BR /&gt;alt_addr        0x000000000000 Alternate EtherChannel Address              True&lt;BR /&gt;auto_recovery   yes            Enable automatic recovery after failover    True&lt;BR /&gt;backup_adapter  NONE           Adapter used when whole channel fails       True&lt;BR /&gt;hash_mode       default        Determines how outgoing adapter is chosen   True&lt;BR /&gt;mode            8023ad         EtherChannel mode of operation              True&lt;BR /&gt;netaddr         0              Address to ping                             True&lt;BR /&gt;noloss_failover yes            Enable lossless failover after ping failure True&lt;BR /&gt;num_retries     3              Times to retry ping before failing          True&lt;BR /&gt;retry_time      1              Wait time (in seconds) between pings        True&lt;BR /&gt;use_alt_addr    no             Enable Alternate EtherChannel Address       True&lt;BR /&gt;use_jumbo_frame no             Enable Gigabit Ethernet Jumbo Frames        True&lt;BR /&gt;&lt;BR /&gt;my code is as follows:&lt;BR /&gt;&lt;BR /&gt;${PREFIX} lsdev -dev ent10 -attr |awk -v ENT=${ENT} -v SLOT=${SLOT} 'BEGIN{OFS=":"}&lt;BR /&gt;&lt;BR /&gt;                                        /^adapter_names/ { split($2,a,","); EN1 = a[1]; EN2 = a[2]; EN=$2 }&lt;BR /&gt;                                        /^backup_adapter/ { BACKUP = $2}&lt;BR /&gt;                                        /^mode/ { MODE = $2}&lt;BR /&gt;                                        {if ( MODE == "8023ad" )} END{print "ETCN",ENT,MODE,EN1,EN2}'&lt;BR /&gt;&lt;BR /&gt;This works and gives me the following output:&lt;BR /&gt;&lt;BR /&gt;ETCN:ent10:8023ad:ent3:ent7&lt;BR /&gt;&lt;BR /&gt;the problem I have is on some systems the mode is standard therefor I have to change the output:&lt;BR /&gt;&lt;BR /&gt;lsdev -dev ent39 -attr&lt;BR /&gt;attribute       value          description                               user_settable&lt;BR /&gt;&lt;BR /&gt;adapter_names   ent36          EtherChannel Adapters                     True&lt;BR /&gt;alt_addr        0x000000000000 Alternate EtherChannel Address            True&lt;BR /&gt;auto_recovery   yes            Enable automatic recovery after failover  True&lt;BR /&gt;backup_adapter  ent37          Adapter used when whole channel fails     True&lt;BR /&gt;hash_mode       default        Determines how outgoing adapter is chosen True&lt;BR /&gt;mode            standard       EtherChannel mode of operation            True&lt;BR /&gt;netaddr                        Address to ping                           True&lt;BR /&gt;num_retries     3              Times to retry ping before failing        True&lt;BR /&gt;retry_time      1              Wait time (in seconds) between pings      True&lt;BR /&gt;use_alt_addr    no             Enable Alternate EtherChannel Address     True&lt;BR /&gt;use_jumbo_frame no             Enable Gigabit Ethernet Jumbo Frames      True&lt;BR /&gt;&lt;BR /&gt;from the above I need to print:&lt;BR /&gt;&lt;BR /&gt;{if ( MODE == "standard" )} END{print "ETCN",ENT,MODE,EN,BACKUP}'&lt;BR /&gt;&lt;BR /&gt;I just cant seem to get the if or else sytax to work.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated and appologies if this isnt clear ....&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Thu, 12 Feb 2009 12:03:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156632#M684139</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T12:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156633#M684140</link>
      <description>&lt;!--!*#--&gt;&amp;gt;{if ( MODE == "8023ad" )} END{print "ETCN",ENT,MODE,EN1,EN2}'&lt;BR /&gt;&lt;BR /&gt;Don't format it like that, it is confusing.  Use:&lt;BR /&gt;{&lt;BR /&gt;if ( MODE == "8023ad" ) print $0&lt;BR /&gt;}&lt;BR /&gt;END{print "ETCN",ENT,MODE,EN1,EN2}'&lt;BR /&gt;&lt;BR /&gt;If you want to add another test, you can use else or "goto" style programming with next.&lt;BR /&gt;BEGIN{OFS=":"}&lt;BR /&gt;/^adapter_names/ { split($2,a,","); EN1 = a[1]; EN2 = a[2]; EN=$2 }&lt;BR /&gt;/^backup_adapter/ { BACKUP = $2}&lt;BR /&gt;/^mode/ { MODE = $2}&lt;BR /&gt;{&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;   do something?&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   do something else?&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END{print "ETCN", ENT, MODE, EN, BACKUP}'&lt;BR /&gt;&lt;BR /&gt;So with this template, what do you want do do?</description>
      <pubDate>Thu, 12 Feb 2009 12:34:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156633#M684140</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-12T12:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156634#M684141</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;To add to Dennis's comment about "goto"s:&lt;BR /&gt;&lt;BR /&gt;Awk (and Perl) offer the 'next' statement.  This can greatly simplify and clarify processing.  In 'awk' the 'next' statement causes processing of the current record to stop without honoring any other rules.  The "next" record is then read.  Perl uses 'next' in this fashion too.&lt;BR /&gt;&lt;BR /&gt;If you use GNU 'awk' ['gawk'] you also have the 'nextfile' statement.  As you might imagine, this causes flow to skip immediately to the next _file_.  This is quite handy if you want to parse a series of files passed on the command line, but only want to process some of each files first few records.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Feb 2009 12:45:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156634#M684141</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-12T12:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156635#M684142</link>
      <description>OK thanks dennis,&lt;BR /&gt;&lt;BR /&gt;I am looking for&lt;BR /&gt;&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  print "ETCN",ENT,MODE,EN1,EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   print "ETCN",ENT,MODE,EN,BACKUP&lt;BR /&gt;&lt;BR /&gt;so I am looking to print a different output depending on the mode.&lt;BR /&gt;&lt;BR /&gt;is there a way I can assign the variables to an OUTPUT VAR and print that at the end ie:&lt;BR /&gt;&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  OUTPUT = ENT,MODE,EN1,EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   OUTPUT = ENT,MODE,EN,BACKUP&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END{print "ENTH",OUTPUT}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Thu, 12 Feb 2009 12:55:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156635#M684142</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T12:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156636#M684143</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; is there a way I can assign the variables to an OUTPUT VAR and print that at the end?&lt;BR /&gt;&lt;BR /&gt;Most certainly.  By example:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{OUTPUT="ENT,MODE,EN1,EN2"};END{print "--&amp;gt;",OUTPUT}' /dev/null&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Feb 2009 13:09:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156636#M684143</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-12T13:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156637#M684144</link>
      <description>almost got it but feel like I've fudged the VAR substitution with the OFS:&lt;BR /&gt;&lt;BR /&gt;${PREFIX} lsdev -dev ent10 -attr |awk -v ENT=${ENT} -v SLOT=${SLOT} '&lt;BR /&gt;BEGIN{OFS=":"}&lt;BR /&gt;/^adapter_names/ { split($2,a,","); EN1 = a[1]; EN2 = a[2]; EN=$2 }&lt;BR /&gt;/^backup_adapter/ { BACKUP = $2}&lt;BR /&gt;/^mode/ { MODE = $2}&lt;BR /&gt;{&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  OUTPUT = ENT":"MODE":"EN1":"EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   OUTPUT = ENT":"MODE":"EN":"BACKUP&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END{print "ETCH:"OUTPUT}'&lt;BR /&gt;&lt;BR /&gt;ETCH:ent10:8023ad:ent3:ent7&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Feb 2009 13:10:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156637#M684144</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T13:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156638#M684145</link>
      <description>ok got that james - I'll give it a whirl ...</description>
      <pubDate>Thu, 12 Feb 2009 13:12:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156638#M684145</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T13:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156639#M684146</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; is there a way I can assign the variables to an OUTPUT VAR and print that at the end ie:&lt;BR /&gt;&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;OUTPUT = ENT,MODE,EN1,EN2&lt;BR /&gt;&lt;BR /&gt;Yeah, easy. Should be:&lt;BR /&gt;&lt;BR /&gt;OUTPUT = ENT FS MODE FS EN1 FS EN2&lt;BR /&gt;&lt;BR /&gt;The FS stands for Field-Seperator and is what would have been used by the PRINT statement.&lt;BR /&gt;&lt;BR /&gt;Standalone example:&lt;BR /&gt;&lt;BR /&gt;$ awk 'BEGIN { a = "AAA"; b = "BBB"; test = a FS b FS a ; print test }'&lt;BR /&gt;AAA BBB AAA&lt;BR /&gt;&lt;BR /&gt;Without FS it would look like:&lt;BR /&gt;&lt;BR /&gt;$ awk 'BEGIN { a = "AAA"; b = "BBB"; test = a b a ; print test }'&lt;BR /&gt;AAABBBAAA&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Feb 2009 13:16:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156639#M684146</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-02-12T13:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156640#M684147</link>
      <description>Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;You have (greatly reduced):&lt;BR /&gt;&lt;BR /&gt;# awk -v ENT="ent" -v SLOT="slot" 'BEGIN{OFS=":"};END{print ENT,SLOT}' /dev/null&lt;BR /&gt;ent:slot&lt;BR /&gt;&lt;BR /&gt;...and one way to rectify this is:&lt;BR /&gt;&lt;BR /&gt;awk -v ENT="ent" -v SLOT="slot" 'BEGIN{OFS=":"};END{printf("%s %s\n",ENT,SLOT)}' /dev/null&lt;BR /&gt;ent slot&lt;BR /&gt;&lt;BR /&gt;...or any formatted output you want.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Feb 2009 13:20:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156640#M684147</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-12T13:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156641#M684148</link>
      <description>ok thanks all,&lt;BR /&gt;&lt;BR /&gt;I now have what I need using a variation of your examples and education:&lt;BR /&gt;&lt;BR /&gt;${PREFIX} lsdev -dev ent10 -attr |awk -v ENT=${ENT} -v SLOT=${SLOT} '&lt;BR /&gt;BEGIN{OFS=":"}&lt;BR /&gt;/^adapter_names/ { split($2,a,","); EN1 = a[1]; EN2 = a[2]; EN=$2 }&lt;BR /&gt;/^backup_adapter/ { BACKUP = $2}&lt;BR /&gt;/^mode/ { MODE = $2}&lt;BR /&gt;{&lt;BR /&gt;if ( MODE == "8023ad" ) {&lt;BR /&gt;  OUTPUT=ENT OFS MODE OFS EN1 OFS EN2&lt;BR /&gt;} else if ( MODE == "standard" ) {&lt;BR /&gt;   OUTPUT = ENT OFS MODE OFS EN OFS BACKUP&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;END{printf("%s\n","ETCH:" OUTPUT)}'&lt;BR /&gt;ETCH:ent10:8023ad:ent3:ent7&lt;BR /&gt;&lt;BR /&gt;although $SLOT is not used here.&lt;BR /&gt;&lt;BR /&gt;Thanks all the same - whats life if you dont learn something new each day &lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;Chris.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Feb 2009 13:28:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156641#M684148</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T13:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156642#M684149</link>
      <description>.</description>
      <pubDate>Thu, 12 Feb 2009 13:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/5156642#M684149</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-02-12T13:29:57Z</dc:date>
    </item>
  </channel>
</rss>

