<?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 how to round robin a variable? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112577#M91707</link>
    <description>I have set an array of ten HTML hex colors to be assigned to a system when printing config data to a HTML document:&lt;BR /&gt;&lt;BR /&gt;clcnt=0&lt;BR /&gt;echo $COLORS |while read INCOLORS&lt;BR /&gt;do&lt;BR /&gt;    (( clcnt +=1 ))&lt;BR /&gt;    OUTCOLOR[$clcnt]=$INCOLORS&lt;BR /&gt;    echo "$clcnt \c"&lt;BR /&gt;    echo ${OUTCOLOR[$clcnt]}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;1 #CC9999&lt;BR /&gt;2 #9999FF&lt;BR /&gt;3 #FFCC88&lt;BR /&gt;4 #FF99FF&lt;BR /&gt;5 #FFFF66&lt;BR /&gt;6 #FF9933&lt;BR /&gt;7 #CC9966&lt;BR /&gt;8 #990099&lt;BR /&gt;9 #006666&lt;BR /&gt;10 #993300&lt;BR /&gt;&lt;BR /&gt;I now need to associate each color with a system that resides in $SysList so when I output the data to HTML I create a table and each cell represents a different system.&lt;BR /&gt;&lt;BR /&gt;How can I associate this data to each lpar in $SysList - I will use the color to represent a system more than once.&lt;BR /&gt;&lt;BR /&gt;any help is much appreciated as always :-)&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris.&lt;BR /&gt;</description>
    <pubDate>Thu, 05 Jun 2008 13:01:28 GMT</pubDate>
    <dc:creator>lawrenzo_1</dc:creator>
    <dc:date>2008-06-05T13:01:28Z</dc:date>
    <item>
      <title>how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112577#M91707</link>
      <description>I have set an array of ten HTML hex colors to be assigned to a system when printing config data to a HTML document:&lt;BR /&gt;&lt;BR /&gt;clcnt=0&lt;BR /&gt;echo $COLORS |while read INCOLORS&lt;BR /&gt;do&lt;BR /&gt;    (( clcnt +=1 ))&lt;BR /&gt;    OUTCOLOR[$clcnt]=$INCOLORS&lt;BR /&gt;    echo "$clcnt \c"&lt;BR /&gt;    echo ${OUTCOLOR[$clcnt]}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;1 #CC9999&lt;BR /&gt;2 #9999FF&lt;BR /&gt;3 #FFCC88&lt;BR /&gt;4 #FF99FF&lt;BR /&gt;5 #FFFF66&lt;BR /&gt;6 #FF9933&lt;BR /&gt;7 #CC9966&lt;BR /&gt;8 #990099&lt;BR /&gt;9 #006666&lt;BR /&gt;10 #993300&lt;BR /&gt;&lt;BR /&gt;I now need to associate each color with a system that resides in $SysList so when I output the data to HTML I create a table and each cell represents a different system.&lt;BR /&gt;&lt;BR /&gt;How can I associate this data to each lpar in $SysList - I will use the color to represent a system more than once.&lt;BR /&gt;&lt;BR /&gt;any help is much appreciated as always :-)&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jun 2008 13:01:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112577#M91707</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2008-06-05T13:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112578#M91708</link>
      <description>seems like you first must set an array with your hex codes then a loop into your systems using a modulo the number max of colors you decided to go through</description>
      <pubDate>Thu, 05 Jun 2008 13:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112578#M91708</guid>
      <dc:creator>Fabien GUTIERREZ</dc:creator>
      <dc:date>2008-06-05T13:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112579#M91709</link>
      <description>if $Syslist is a string&lt;BR /&gt;"sys1 sys2 sys3" for instance&lt;BR /&gt;typeset -i idxsys=0&lt;BR /&gt;typeset -i idxcol=0&lt;BR /&gt;for i in $Syslist&lt;BR /&gt;do&lt;BR /&gt;   SYSNAME[$idxsys]=$i&lt;BR /&gt;   SYSCOL[$idxsys]=${OUTCOLOR[$idxcol]}&lt;BR /&gt;   idxsys=idxsys+1&lt;BR /&gt;   idxcol=idxsys%${clcnt}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;or you can&lt;BR /&gt;typeset -i idxsys=0&lt;BR /&gt;typeset -i idxcol=0&lt;BR /&gt;for i in $Syslist&lt;BR /&gt;do&lt;BR /&gt;   eval "SYSCOL_${i}=${OUTCOLOR[$idxcol]}"&lt;BR /&gt;   idxsys=idxsys+1&lt;BR /&gt;   idxcol=idxsys%${clcnt}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Then you can use eval echo $"{SYSCOL_${i}}"</description>
      <pubDate>Thu, 05 Jun 2008 13:43:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112579#M91709</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2008-06-05T13:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112580#M91710</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;We use the following snippet to randomly assign dbspaces at login time:&lt;BR /&gt;&lt;BR /&gt;NUMBER=`date +%S | cut -c2,2`&lt;BR /&gt;set +A LINE_ARRAY `cat /etc/dbspace`&lt;BR /&gt;DBSPACETEMP=${LINE_ARRAY[$NUMBER]}&lt;BR /&gt;export DBSPACETEMP&lt;BR /&gt;&lt;BR /&gt;where /etc/dbspace looks like this:&lt;BR /&gt;&lt;BR /&gt;$ cat /etc/dbspace&lt;BR /&gt;dbs14 dbs13 dbs12 dbs11 dbs09 dbs10 dbs14 dbs13 dbs12&lt;BR /&gt;&lt;BR /&gt;I think it would be simple to adapt this for your use.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 05 Jun 2008 14:33:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112580#M91710</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2008-06-05T14:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112581#M91711</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;You could use 'awk' to generate a random index into your array if you like:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{srand();printf("%d\n",(1+int(rand()*10)))}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jun 2008 14:48:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112581#M91711</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-06-05T14:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112582#M91712</link>
      <description>Did I call that or what?&lt;BR /&gt;&lt;BR /&gt;See: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1238236" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1238236&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;What problem are you really trying to solve?&lt;BR /&gt;&lt;BR /&gt;Once you have an lpar - color association, then how/where will that be used?&lt;BR /&gt;What will be the 'driver'? &lt;BR /&gt;That $SysList or something else still?&lt;BR /&gt;&lt;BR /&gt;$  perl -e '@sys=&amp;lt;&amp;gt;; @colors=split /\s+/, $ENV{COLORS}; for $i (1..@sys) { print "$i $colors[$i-1] $sys[$i-1]" }' $SysList&lt;BR /&gt;1 #CC9999 aap&lt;BR /&gt;2 #9999FF noot&lt;BR /&gt;3 #FFCC88 mies&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Jun 2008 15:17:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112582#M91712</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-06-05T15:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112583#M91713</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Another way using Perl hashes (known in 'awk' as associative arrays):&lt;BR /&gt;&lt;BR /&gt;# cat myref&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $sys = shift or die "systemId expected\n";&lt;BR /&gt;my %colors = (&lt;BR /&gt;    sys1  =&amp;gt; '#CC9999',&lt;BR /&gt;    sys2  =&amp;gt; '#9999FF',&lt;BR /&gt;    sys3  =&amp;gt; '#FFCC88',&lt;BR /&gt;    sys4  =&amp;gt; '#FF99FF',&lt;BR /&gt;    sys5  =&amp;gt; '#FFFF66',&lt;BR /&gt;    sys6  =&amp;gt; '#FF9933',&lt;BR /&gt;    sys7  =&amp;gt; '#CC9966',&lt;BR /&gt;    sys8  =&amp;gt; '#990099',&lt;BR /&gt;    sys9  =&amp;gt; '#006666',&lt;BR /&gt;    sys10 =&amp;gt; '#993300'&lt;BR /&gt;);&lt;BR /&gt;if ( exists $colors{$sys} ) {&lt;BR /&gt;    print "$colors{$sys}\n";&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;    print "#000000\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...run passing the "system" for which you want to find the color:&lt;BR /&gt;&lt;BR /&gt;# ./myref sys3&lt;BR /&gt;#FFCC88&lt;BR /&gt;&lt;BR /&gt;# ./myref badsys&lt;BR /&gt;#000000&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Jun 2008 21:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112583#M91713</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-06-05T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112584#M91714</link>
      <description>&lt;!--!*#--&gt;Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;...and the last Perl solution hacked in 'awk':&lt;BR /&gt;&lt;BR /&gt;# cat ./myref&lt;BR /&gt;#!/usr/bin/awk -f&lt;BR /&gt;END{&lt;BR /&gt;    colors["sys1"]="#CC9999"&lt;BR /&gt;    colors["sys2"]="#9999FF"&lt;BR /&gt;    colors["sys3"]="#FFCC88"&lt;BR /&gt;    colors["sys4"]="#FF99FF"&lt;BR /&gt;    colors["sys5"]="#FFFF66"&lt;BR /&gt;    colors["sys6"]="#FF9933"&lt;BR /&gt;    colors["sys7"]="#CC9966"&lt;BR /&gt;    colors["sys8"]="#990099"&lt;BR /&gt;    colors["sys9"]="#006666"&lt;BR /&gt;    colors["sys10"]="#993300"&lt;BR /&gt;if ($1 in colors)&lt;BR /&gt;    print colors[$1]&lt;BR /&gt;else&lt;BR /&gt;    print "#000000"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# echo sys8 | ./myref&lt;BR /&gt;#990099&lt;BR /&gt;&lt;BR /&gt;...oh, I so much prefer Perl :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Jun 2008 23:45:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112584#M91714</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-06-05T23:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112585#M91715</link>
      <description>NICE ...&lt;BR /&gt;&lt;BR /&gt;I'll take a look at the exapmles and adapt for my purpose!&lt;BR /&gt;&lt;BR /&gt;thanks again&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Fri, 06 Jun 2008 07:28:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112585#M91715</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2008-06-06T07:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to round robin a variable?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112586#M91716</link>
      <description>thanks all for the advise and help ...&lt;BR /&gt;&lt;BR /&gt;the solution that I found worked best to my skills and uderstanding:&lt;BR /&gt;&lt;BR /&gt;for LPAR in $LparList&lt;BR /&gt;do&lt;BR /&gt;    LPARNAME[$idlpar]=$LPAR&lt;BR /&gt;    LPARCOL[$idlpar]=${outcolor[$idxcol]}&lt;BR /&gt;    idlpar=idlpar+1&lt;BR /&gt;    idxcol=idlpar%${clcnt}&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Jun 2008 13:03:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-round-robin-a-variable/m-p/5112586#M91716</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2008-06-06T13:03:16Z</dc:date>
    </item>
  </channel>
</rss>

