<?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: Counter function problems... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151117#M90631</link>
    <description>&lt;!--!*#--&gt;I fixed it by combining them into one:&lt;BR /&gt;&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;function adder_func&lt;BR /&gt;         {&lt;BR /&gt;         TYPE=$1&lt;BR /&gt;         if [ -s sizes.$TYPE ]; then&lt;BR /&gt;            let sum=0&lt;BR /&gt;            for i in `cat sizes.$TYPE`&lt;BR /&gt;            do&lt;BR /&gt;             ((i=$i-5104))&lt;BR /&gt;             ((new_sum=$i + $sum))&lt;BR /&gt;             sum=$new_sum&lt;BR /&gt;            done&lt;BR /&gt;            ((meg_sum=$new_sum/1024))&lt;BR /&gt;            ((gig_sum=$meg_sum/1024))&lt;BR /&gt;            ((last_sum=$gig_sum*$NUMBER))&lt;BR /&gt;            echo ${last_sum}G&lt;BR /&gt;           else&lt;BR /&gt;            break&lt;BR /&gt;          fi&lt;BR /&gt;         }&lt;BR /&gt;&lt;BR /&gt;## Call the adder_func function and output to value.txt to get the max size for your lvol.&lt;BR /&gt;adder_func size &amp;gt; value.txt&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;&lt;BR /&gt;And now the output of value.txt:&lt;BR /&gt;2495G&lt;BR /&gt;&lt;BR /&gt;And the effect:&lt;BR /&gt;&lt;BR /&gt;Are you ready to create a lvol in fakedg?&lt;BR /&gt;Enter 'y' for Yes or 'n' for No :y&lt;BR /&gt;&lt;BR /&gt;Enter the name of your lvol.&lt;BR /&gt;&lt;BR /&gt;Lvol name :fakelvol&lt;BR /&gt;&lt;BR /&gt;Enter the size of  your lvol.&lt;BR /&gt;The maximum size is: 2495G&lt;BR /&gt;&lt;BR /&gt;Lvol size :&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 27 Feb 2008 01:03:32 GMT</pubDate>
    <dc:creator>Patrick Ware_1</dc:creator>
    <dc:date>2008-02-27T01:03:32Z</dc:date>
    <item>
      <title>Counter function problems...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151114#M90628</link>
      <description>&lt;!--!*#--&gt;Ok, here is the issue I have..  &lt;BR /&gt;&lt;BR /&gt;I wrote a script that builds disk groups using vxvm, and it works really good.  I added a feature that would tell you the max size you could build your your lvol to.  I do this by getting the size of the disks I am using in KB,  I subtract 5104 from it, and then I multiply it by the number of disks I am using to build my disk group.  I set this to a variable called $NUMBER for use throughout the script.  The function is finished, it outputs the answer to a file called value.txt.  For some reason it works great until $NUMBER = 5 or more.&lt;BR /&gt;&lt;BR /&gt;Below is the section of the script that is giving me issues:&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;function adder_func&lt;BR /&gt;         {&lt;BR /&gt;         TYPE=$1&lt;BR /&gt;         if [ -s sizes.$TYPE ]; then&lt;BR /&gt;            let sum=0&lt;BR /&gt;            for i in `cat sizes.$TYPE`&lt;BR /&gt;            do&lt;BR /&gt;             ((i=$i - 5104))&lt;BR /&gt;             ((new_sum=$i + $sum))&lt;BR /&gt;             sum=$new_sum&lt;BR /&gt;            done&lt;BR /&gt;            ((last_sum=$new_sum*$NUMBER))&lt;BR /&gt;            echo ${last_sum}&lt;BR /&gt;           else&lt;BR /&gt;            break&lt;BR /&gt;          fi&lt;BR /&gt;         }&lt;BR /&gt;&lt;BR /&gt;## Call the adder_func function and output to value.txt to get the max size for your lvol.&lt;BR /&gt;adder_func size &amp;gt; value.txt&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;When the function is  with an option called 'size' it reads from a file called sizes.size (sizes.$TYPE).  As you see, the size option is the same as the $TYPE variable.&lt;BR /&gt;&lt;BR /&gt;Output from sizes.size (which is the size of the disks in KB):&lt;BR /&gt;524288000&lt;BR /&gt;&lt;BR /&gt;Here is the output from value.txt when the $NUMBER variable = 5:&lt;BR /&gt;-1149269920&lt;BR /&gt;&lt;BR /&gt;When I do the math, of course it shouldn't be a large negative number:&lt;BR /&gt;&lt;BR /&gt;root@werver:/root_home&amp;gt; bc -l&lt;BR /&gt;524288000-5104&lt;BR /&gt;524282896&lt;BR /&gt;524282896*5&lt;BR /&gt;2621414480&lt;BR /&gt;&lt;BR /&gt;So it should be 2621414480 or 2499.97GB, or about 2.5TB.  Am I surpassing the numerical limits of the function?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Feb 2008 23:35:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151114#M90628</guid>
      <dc:creator>Patrick Ware_1</dc:creator>
      <dc:date>2008-02-26T23:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Counter function problems...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151115#M90629</link>
      <description>Hi Patrick:&lt;BR /&gt;&lt;BR /&gt;Shell arithmetic is 32-bit so, yes, you have exceeded its ability.&lt;BR /&gt;&lt;BR /&gt;You could use 'bc', Perl or simply scale your math by 1024 or 1024*1024 to reach a reasonable approximation.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 27 Feb 2008 00:02:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151115#M90629</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-02-27T00:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Counter function problems...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151116#M90630</link>
      <description>&lt;!--!*#--&gt;I see.  I actually have a second function to do scaling down to GB readable text.&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;function adder_func2&lt;BR /&gt;         {&lt;BR /&gt;         TYPE=$1&lt;BR /&gt;         if [ -s value.$TYPE ]; then&lt;BR /&gt;           let sum=0&lt;BR /&gt;           for i in `cat value.$TYPE`&lt;BR /&gt;              do&lt;BR /&gt;               ((i=$i/1024))&lt;BR /&gt;               ((new_sum=$i + $sum))&lt;BR /&gt;               sum=$new_sum&lt;BR /&gt;           done&lt;BR /&gt;               ((gig_sum=$new_sum/1024))&lt;BR /&gt;          echo ${gig_sum}G&lt;BR /&gt;         else&lt;BR /&gt;          break&lt;BR /&gt;         fi&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;## Call the adder_func2 function and output to value2.txt to get the&lt;BR /&gt;## max size for your lvol in GB.&lt;BR /&gt;adder_func2 txt &amp;gt; value2.txt&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;When the function is ran with an option called 'txt' it reads from a file called value.txt (value.$TYPE).  As you see, the txt option is the same as the $TYPE variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here is the output of value2.txt, which just took the value from value.txt (-1149269920) and divided it by 1024 twice:&lt;BR /&gt;-1096G&lt;BR /&gt;&lt;BR /&gt;This is why I would do such a thing:&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;VALUE=`cat value.txt`&lt;BR /&gt;VALUE2=`cat value2.txt`&lt;BR /&gt;echo "Enter the size of  your lvol."&lt;BR /&gt;echo "The maximum size is: $VALUE or $VALUE2 "&lt;BR /&gt;echo&lt;BR /&gt;print -n "Lvol size :"&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;This is the resulting output:&lt;BR /&gt;&lt;BR /&gt;Enter the size of  your lvol.&lt;BR /&gt;The maximum size is: -1149269920 or -1096G&lt;BR /&gt;&lt;BR /&gt;I want to give the option of both KB or GB readable for size options, but it looks like it may be better to just scale to GB readable, and be done with it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Perhaps I should combine the two.&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Feb 2008 00:45:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151116#M90630</guid>
      <dc:creator>Patrick Ware_1</dc:creator>
      <dc:date>2008-02-27T00:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Counter function problems...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151117#M90631</link>
      <description>&lt;!--!*#--&gt;I fixed it by combining them into one:&lt;BR /&gt;&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;function adder_func&lt;BR /&gt;         {&lt;BR /&gt;         TYPE=$1&lt;BR /&gt;         if [ -s sizes.$TYPE ]; then&lt;BR /&gt;            let sum=0&lt;BR /&gt;            for i in `cat sizes.$TYPE`&lt;BR /&gt;            do&lt;BR /&gt;             ((i=$i-5104))&lt;BR /&gt;             ((new_sum=$i + $sum))&lt;BR /&gt;             sum=$new_sum&lt;BR /&gt;            done&lt;BR /&gt;            ((meg_sum=$new_sum/1024))&lt;BR /&gt;            ((gig_sum=$meg_sum/1024))&lt;BR /&gt;            ((last_sum=$gig_sum*$NUMBER))&lt;BR /&gt;            echo ${last_sum}G&lt;BR /&gt;           else&lt;BR /&gt;            break&lt;BR /&gt;          fi&lt;BR /&gt;         }&lt;BR /&gt;&lt;BR /&gt;## Call the adder_func function and output to value.txt to get the max size for your lvol.&lt;BR /&gt;adder_func size &amp;gt; value.txt&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;&lt;BR /&gt;And now the output of value.txt:&lt;BR /&gt;2495G&lt;BR /&gt;&lt;BR /&gt;And the effect:&lt;BR /&gt;&lt;BR /&gt;Are you ready to create a lvol in fakedg?&lt;BR /&gt;Enter 'y' for Yes or 'n' for No :y&lt;BR /&gt;&lt;BR /&gt;Enter the name of your lvol.&lt;BR /&gt;&lt;BR /&gt;Lvol name :fakelvol&lt;BR /&gt;&lt;BR /&gt;Enter the size of  your lvol.&lt;BR /&gt;The maximum size is: 2495G&lt;BR /&gt;&lt;BR /&gt;Lvol size :&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Feb 2008 01:03:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151117#M90631</guid>
      <dc:creator>Patrick Ware_1</dc:creator>
      <dc:date>2008-02-27T01:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Counter function problems...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151118#M90632</link>
      <description>Hi (again) Patrick:&lt;BR /&gt;&lt;BR /&gt;As an aside:&lt;BR /&gt;&lt;BR /&gt;# VALUE=`cat value.txt`&lt;BR /&gt;&lt;BR /&gt;...is faster if you do (instead):&lt;BR /&gt;&lt;BR /&gt;# VALUE=$(&lt;VALUE.TXT&gt;&lt;/VALUE.TXT&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 27 Feb 2008 01:13:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/counter-function-problems/m-p/4151118#M90632</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-02-27T01:13:06Z</dc:date>
    </item>
  </channel>
</rss>

