Sponsored Content
Full Discussion: Counter function problems...
Top Forums Shell Programming and Scripting Counter function problems... Post 302170806 by LinuxRacr on Tuesday 26th of February 2008 06:36:25 PM
Old 02-26-2008
Counter function problems...

Ok, here is the issue I have..

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.

Below is the section of the script that is giving me issues:
Code:
function adder_func
         {
         TYPE=$1
         if [ -s sizes.$TYPE ]; then
            let sum=0
            for i in `cat sizes.$TYPE`
            do
             ((i=$i - 5104))
             ((new_sum=$i + $sum))
             sum=$new_sum
            done
            ((last_sum=$new_sum*$NUMBER))
            echo ${last_sum}
           else
            break
          fi
         }

## Call the adder_func function and output to value.txt to get the max size for your lvol.
adder_func size > value.txt

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.

Output from sizes.size (which is the size of the disks in KB):
524288000

Here is the output from value.txt when the $NUMBER variable = 5:
-1149269920

When I do the math, of course it shouldn't be a large negative number:

root@server:/root_home> bc -l
524288000-5104
524282896
524282896*5
2621414480

So it should be 2621414480 or 2499.97GB, or about 2.5TB.

Am I surpassing the numerical limits of the function?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

counter in a variable - can it be done?

I have the following for(( i=1; 1<=2; i++)) do e1=123 n1=123 e2=456 n2=456 coord= $e1,$n1 echo "coordinate=$coord" done exit this echos coordinate=123,123 I need it to loop so: loop1 coord=$e1,$n1 loop2 (3 Replies)
Discussion started by: gazz1982
3 Replies

2. Shell Programming and Scripting

Counter Script..help please

I have generated a script that will email a list of people if a certain PID is not running, using "mailx". I have the script running every 5 minutes as a cron job. I want the script to stop sending an email, if the email has been sent 5 times (meaning PID is dead). I want this so that my... (3 Replies)
Discussion started by: Sunguy222
3 Replies

3. Programming

Please help! accept function problems in Socket programming

Hi, I have a client-server socket program. It has been working fine for over a year, but recently it started to show strange behavior.:confused: After the server program runs for a while, it will show in the top command saying it is using lots of CPU, MEM. I assume it means the server code is... (1 Reply)
Discussion started by: natxie
1 Replies

4. Shell Programming and Scripting

counter

Hi, I need some help. Shell script counter. i need to add condition to check if counter is more than 10 and longer than 3 hours? it runs every 5 mins. it only check count and send email right now. it runs in cron as below gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err ... (1 Reply)
Discussion started by: pega
1 Replies

5. Shell Programming and Scripting

DelimiterCount: how to use a counter

Hi, I am new to shell script. I want to count to Delimiter count for my source file. For that I have written script. When I tried to execute the script I could not able to view the results. It throws errors. I don't know what the problem is. My aim is I want to store the delimiter count in one... (4 Replies)
Discussion started by: suresh01_apk
4 Replies

6. Shell Programming and Scripting

"help me!!" if and function problems

I am trying to allow the user to be notified that the id has already taken from the file "record" and that the user has to contain a numerical figure as well. however when i run it, it will only stay at the please enter a number section and does not change. do u know where is the problem? ... (2 Replies)
Discussion started by: bassmasta1
2 Replies

7. UNIX for Dummies Questions & Answers

Problems with "exit" called from function in bourne script

Hi everyone. #!/sbin/sh EXITING() { umount /FOLDER rm -Rf /FOLDER echo "EXIT" exit 0 } EXITING echo "OK" (8 Replies)
Discussion started by: vacadepollo
8 Replies

8. Programming

Problems with JNI and currentTimeMillis function

Hello, I have a technical problem: I work on AIX 7.1 with Java 1.7 (32 and 64 bit) and I make an application that intercepts certain functions related to time. In this application there is a Java JNI agent with whom I can intercept the Java "getLastModifiedTime" no problem but I am unable to... (5 Replies)
Discussion started by: steph311
5 Replies

9. Shell Programming and Scripting

Counter

if ;then echo "mrnet greater 5000" gzip /var/log/mrnet.log mv /var/log/mrnet.log.gz /var/log/mrnet.log.1.gz if ];then i=1 let i++ mv /var/log/mrnet.log.1.gz /var/log/vieux-logs/mrnet.log.$i.gz else echo "theres no... (1 Reply)
Discussion started by: Froob
1 Replies

10. UNIX for Dummies Questions & Answers

Pegging counter

Hi Experts, I am in need for some help. My competence level on unix is not at all helping me to resolve this. Please help. My Input for a system command is as under: Counters are getting pegged each hour. I need to have a difference printed rather than pegged counter values. Counter... (2 Replies)
Discussion started by: vanand420
2 Replies
getpagesizes(3C)					   Standard C Library Functions 					  getpagesizes(3C)

NAME
getpagesizes - get system supported page sizes SYNOPSIS
#include <sys/mman.h> int getpagesizes(size_t pagesize[], int nelem); DESCRIPTION
The getpagesizes() function returns either the number of different page sizes supported by the system or the actual sizes themselves. When called with nelem as 0 and pagesize as NULL, getpagesizes() returns the number of supported page sizes. Otherwise, up to nelem page sizes are retrieved and assigned to successive elements of pagesize[]. The return value is the number of page sizes retrieved and set in page- size[]. RETURN VALUES
Upon successful completion, the number of pagesizes supported or actually retrieved is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The getpagesizes() function will fail if: EINVAL The nelem argument is less than 0 or pagesize is NULL but nelem is non-zero. USAGE
The getpagesizes() function returns all the page sizes for which the hardware and system software provide support for the memcntl(2) com- mand MC_HAT_ADVISE. Not all processors support all page sizes or combinations of page sizes with equal efficiency. Applications programmers should take this into consideration when using getpagesizes(). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
memcntl(2), mmap(2), getpagesize(3C), attributes(5) SunOS 5.11 14 May 2001 getpagesizes(3C)
All times are GMT -4. The time now is 09:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy