Sponsored Content
Full Discussion: Counter function problems...
Top Forums Shell Programming and Scripting Counter function problems... Post 302170819 by LinuxRacr on Tuesday 26th of February 2008 08:58:32 PM
Old 02-26-2008
I fixed it by combining two functions into one:

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
            ((meg_sum=$new_sum/1024))
            ((gig_sum=$meg_sum/1024))
            ((last_sum=$gig_sum*$NUMBER))
            echo ${last_sum}G
           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

Now everything will be GigaByte readable, instead of in KBytes.

And now the output of value.txt:
2495G

And the effect:

Are you ready to create a lvol in fakedg?
Enter 'y' for Yes or 'n' for No :y

Enter the name of your lvol.

Lvol name :fakelvol

Enter the size of your lvol.
The maximum size is: 2495G

Lvol size :
 

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
sum(n)									sum								    sum(n)

NAME
sum - calculate a sum(1) compatible checksum SYNOPSIS
package require Tcl 8.2 package require sum ?1.0? ::crc::sum ?-format format? message ::crc::sum ?-format format? -filename file DESCRIPTION
This package provides a Tcl-only implementation of the sum(1) command which calculates a 16 bit checksum value from the input data. The BSD sum algorithm is used by default but the SysV algorithm is also available. COMMANDS
::crc::sum ?-format format? message ::crc::sum ?-format format? -filename file The command takes string data or a file name and returns a checksum value calculated using the sum(1) algorithm. The result is for- matted using the format(n) specifier provided or as an unsigned integer (%u) by default. OPTIONS
-filename name Return a checksum for the file contents instead of for parameter data. -format string Return the checksum using an alternative format template. EXAMPLES
% crc::sum "Hello, World!" 37287 % crc::sum -format 0x%X "Hello, World!" 0x91A7 % crc::sum -file sum.tcl 13392 SEE ALSO
sum(1), cksum(n), crc32(n) AUTHORS
Pat Thoyts KEYWORDS
sum, cksum, checksum, crc, crc32, cyclic redundancy check, data integrity, security crc 1.0 sum(n)
All times are GMT -4. The time now is 11:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy