Sponsored Content
Top Forums Shell Programming and Scripting Help me streamline this counting part of my script. Post 302170700 by LinuxRacr on Tuesday 26th of February 2008 12:55:22 PM
Old 02-26-2008
Yes, it worked. Thank you. Here is what I did:
Code:
## Increment the counter based on NUMBER, and output to count.txt
case $NUMBER
   in
       1) continue ;;

       2) alphabet="02";;
       3) alphabet="02 03";;
       4) alphabet="02 03 04";;
       5) alphabet="02 03 04 05";;
       6) alphabet="02 03 04 05 06";;
       7) alphabet="02 03 04 05 06 07";;
       8) alphabet="02 03 04 05 06 07 08";;
       9) alphabet="02 03 04 05 06 07 08 09";;
      10) alphabet="02 03 04 05 06 07 08 09 10";;
      11) alphabet="02 03 04 05 06 07 08 09 10 11";;
      12) alphabet="02 03 04 05 06 07 08 09 10 11 12";;
      13) alphabet="02 03 04 05 06 07 08 09 10 11 12 13";;
      14) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14";;
      15) alphabet="02 03 04 05 06 07 08 09 10 11 12 14 14 15";;
      16) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14 15 16";;
      17) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17";;
      18) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18";;
      19) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19";;
      20) alphabet="02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20";;
esac
count=0
for letter in $alphabet
do
    count=`expr $count + 1`
    echo "$letter"
done > count.txt

The output of count.txt when $NUMBER is 6:
02
03
04
05
06

And here is the ultimate goal of all the counting (the output of the disk adding script I wrote is below)
NOTE: I commented out the actual lines that add the disks, so there will be a few errors below due to the fact that it is not actually adding disks, but only printing the commands to screen.:

Code:
This script is only to be used when building NEW DISK GROUPS ONLY!!
that will be using VXVM 4.1 or higher to manage disks, with no rootdg.
This version is an option for striping.

Have you ran the inq script?
Enter 'y' for Yes or 'n' for No :y

Chose the type of external storage
you will be working with.  Your choices
are 'EMC' and 'EVA' (EVA = HSV).

Enter 'EMC' or 'EVA'. Disk type? :eva


Disk sizes that are available are:
524288000
What size disk do you want to use?
Disk size? :524288000

There are 11 HSV disks of this size available.

How many do you want to use(20 disks max!)
to create your diskgroup? :6

What will the name of y our diskgroup?
Ensure that the name of your diskgroup
ends with 'dg', or there will be problems!!!
For example(s).. 'datadg'...or 'p1vma1c1dg'.

Diskgroup Name :fakedg

vxdg init fakedg fakedg01=c10t0d6

vxdg -g fakedg adddisk fakedg02=c10t0d7
vxdg -g fakedg adddisk fakedg03=c10t1d0
vxdg -g fakedg adddisk fakedg04=c10t1d1
vxdg -g fakedg adddisk fakedg05=c10t1d2
vxdg -g fakedg adddisk fakedg06=c10t1d3

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: -1149269920 or -1096G <-- Wrong value is due to a bug in the script when I use 5 or more disks...

Lvol size :2G

Enter the block size of  your lvol.

Lvol block size :8192

Do you need to do any striping?
Enter 'y' for Yes or 'n' for No :y

What is the size of your strpewidth?
Stripewidth size :128

What is the number of disks that will be striped across?
NOTE: You just created diskgroup fakedg with 6 disks.

Enter a value for 'nstripe' :6

vxassist -g fakedg make fakelvol 2G fakedg01 fakedg02 fakedg03 fakedg04 fakedg05 fakedg06  layout=stripe nstripe=6 stripewidth=128

mkfs -F vxfs -o largefiles -o bsize=8192 /dev/vx/dsk/fakedg/fakelvol

VxVM vxassist ERROR V-5-1-607 Diskgroup fakedg not found
VxVM vxassist ERROR V-5-1-607 Diskgroup fakedg not found
This is how much space you have left in the diskgroup fakedg:
<Nothing listed here, because script is not actually executing the commands>

This is the max size your lvol can be:
<Nothing listed here, because script is not actually executing the commands>

Do you want to max out the size of your lvol?
Enter 'y' for Yes or 'n' for No :n


Last edited by LinuxRacr; 02-26-2008 at 07:15 PM..
 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

counting in shell script

hi i am writing a korn shell script to compile all programs there are arount 2000+ files now i have a script that can compile programs but i want to show status of compilation because to compile all programs it takes around 10-15 mins so how can i display status like it should print no of files... (3 Replies)
Discussion started by: zedex
3 Replies

2. Shell Programming and Scripting

Streamline script to search for numbers in a certain range

Hello all, I need help making a script run faster since I have a huge file to sift through. The file I am running my script on looks like this: 1 -1.9E+001 -1.8E-001 1.5E+001 3.32E+001 2 -1.7E+001 -1.0E-002 1.2E+001 6.37E+001 3 -1.5E+001 -3.8E-006 6.7E+001 4.81E+001 The... (12 Replies)
Discussion started by: butson
12 Replies
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy