Sponsored Content
Full Discussion: Please correct the code
Top Forums Shell Programming and Scripting Please correct the code Post 302252317 by mansa on Wednesday 29th of October 2008 09:13:08 AM
Old 10-29-2008
Hi,

Some part of output:
================
$ hwmgr show scsi
SCSI DEVICE DEVICE DRIVER NUM DEVICE FIRST
HWID: DEVICEID HOSTNAME TYPE SUBTYPE OWNER PATH FILE VALID PATH
-------------------------------------------------------------------------
68: 0 mullins disk none 0 1 dsk0 [0/0/0]
69: 1 mullins disk none 0 1 dsk1 [0/1/0]
71: 4 mullins disk none 0 4 scp0 [2/0/0]
72: 5 mullins disk none 2 4 dsk2 [2/0/3]
73: 6 mullins disk none 2 4 dsk3 [2/0/4]
74: 7 mullins disk none 2 4 dsk4 [2/0/6]
75: 8 mullins disk none 2 4 dsk5 [2/0/7]
76: 9 mullins disk none 2 4 dsk6 [2/0/8]
77: 10 mullins disk none 0 4 dsk7 [2/0/9]
78: 11 mullins disk none 0 4 dsk8 [2/0/10]
79: 12 mullins disk none 0 4 dsk9 [2/0/11]
80: 13 mullins disk none 0 4 dsk10 [2/0/12]
================================================================
Main intention of doing this is to meet BID value=35 by using required number of disks.
a[x]=x (unknown value to programmer)varies from machine to machine.
And a[x] value can be found from below code ..
hwmgr show scsi > scsi.tmp
while read line; do
a[x]=`echo $line | grep "dsk" | awk '{ print $7 }'`
Coming to BID concept:
--------------------------------
BID value =(No of partitions * NUM PATH value).
In general each disk has 4 partitions (a,b,g,h) and and for each partition(a,b,g,h) their wll be NUM PATH value.Each partition NUM PATH value will be equal to NUM PATH value of that particular disk.
Example:- Suppose dsk1 has NUM PATH=4 then partition "a" has Total number of paths=4 partition "b" total number of paths=4 Partition "g" total number of paths=4 partition "h" total number of paths=4 Hence,if you use dsk1 then we can have BID value=(No of partitions * NUM PATH)=4*4=16.

So our requirement is to meet BID value=35.
After getting NUM PATH value by above code,we must use the required number of disks to meet BID=35.
Example:Let say dsk2 and dsk3 has NUMPATH=4 then we can get BID value=16+16=32) Still we didnt meet BID=35 and here we must note that we can't use the disk which has NUM PATH=4 now at this stage because 32+4=36 (not equal to 35) so we must use less than NUM PATH=4 , say if you find NUM PATH=1(less than NUM PATH=4)so we can proceede and here we must check how many partitions to be used to meet BID value=35.In this case only 3 partitions are required which has NUM PATH=1 so finally
32+3=35..
========================================================
I wrote the below code as per my above information..

Code:
#!/bin/ksh
main() {
set -x
int a[10],b[10];
# array a and b are used to store the paths and partitions for the disks until we get the 
proper BID Value
int x = 0,y = 0, BID = 0;
int count=0,t=0;
while [[ $BID -le 35 ]] ; do
x=`expr $x + 1`;
hwmgr show scsi > scsi.tmp
while read line; do
a[x]=`echo $line | grep "dsk" | awk '{ print $7 }'`
done < scsi.tmp
b[x]=4;
BID+=a[x].b[x];
echo $BID;
if [[ $BID -gt 35 ]]; then
y = $BID - 35;
echo $y;
BID-= a[x].b[x];
if [[ count -eq 0 ]]; then
for i in b[x] ; do
t = a[x].i;
if [[ $y -eq $t ]] ; then
b[x] -= i;
BID += a[x].b[x];
count = 0;
break;
fi
count=1;
done
else
if [[ $count -eq 1 ]] ; then
a[x]=0;
b[x]=0;
fi
fi
else
if [[ $BID -eq 35 ]] ; then
break;
fi
fi
done
return;
}

Could you check it and correct me if you have better idea..
Request you to please provide inputs for this...
Image
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can any body correct the code

#!/bin/ksh LOG_DATE=`date +%Y%m` export LOG_DATE cd D:/Informatica/Informatica_share/SrcFiles/l # mv SITE_ACTIVITY${LOG_DATE}*.CSV D:/Informatica/Informatica_share/SrcFiles/SITE_ACTIVITY${LOG_DATE}*.CSV # mv SITE_ACTIVITY20050914114546.CSV... (6 Replies)
Discussion started by: vivekanandarpat
6 Replies

2. UNIX for Advanced & Expert Users

can any body correct the code

#!/bin/ksh LOG_DATE=`date +%Y%m` export LOG_DATE cd D:/Informatica/Informatica_share/SrcFiles/l # mv SITE_ACTIVITY${LOG_DATE}*.CSV D:/Informatica/Informatica_share/SrcFiles/SITE_ACTIVITY${LOG_DATE}*.CSV # mv SITE_ACTIVITY20050914114546.CSV... (2 Replies)
Discussion started by: vivekanandarpat
2 Replies

3. Shell Programming and Scripting

Please correct this

I have input file like this Input file: ABC|abc_etc_passwd XYZ|XYZ_etc_passwd zXY|XYZ_etc_passwd IJK|test_etc_passwd KLM|test_etc_passwd i want to do following in a loop. grep 'ABC' *abc_etc_passwd* grep 'XYZ' *XYZ_etc_passwd* grep 'ZXY' *ZXY_etc_passwd* i have tried this for i... (2 Replies)
Discussion started by: pinnacle
2 Replies

4. Solaris

in correct drive name

I am new to solaris and I replaced a faulty tape drive sun DLT7000 But, I am getting the follwoing error when system reboots ltid deamon error drive index 1 is not correct, drive name /dev/rmt/2cbn is incorrect no such file or directory. I have two drives the other one is /dev/rmt/0cbn,... (8 Replies)
Discussion started by: latif1958
8 Replies

5. Linux

Please correct me with my code?

Dear All On my Linux server, I need to separate the individual logs coming from various modules concurrently. Please find below a sample of the logs: But when I run it, I am receiving the following error: -bash: -f1.log : command not found -bash: $LOGFILE : ambiguous redirect Can you... (4 Replies)
Discussion started by: hadimotamedi
4 Replies

6. Shell Programming and Scripting

Please Correct My script

############### #filename.sh ############### CUREENT_DATE=02 log_file_path="$CUREENT_DATE"-"${0##%*/}`|cut -d "." -f1|awk -F "/" '{print $NF}'`"".log" echo $log_file_path ################ #output required 02-filename.log (6 Replies)
Discussion started by: mohitmehral
6 Replies

7. Shell Programming and Scripting

Send correct exit code from child script back to parent

Hello all; hope someone can help me cause I am going crazy trying to find a solution for (what I think is simple) issue...looked hard up and down this forum and tried several "solutions" with no avail...so here's my issue: I have this (parent) script: copylsofdcmcadefttosftpwithmove.sh ... (3 Replies)
Discussion started by: gvolpini
3 Replies

8. Shell Programming and Scripting

Help to correct dnsscript.

Hello Brains, I was trying to develop a script that would do nslookup using both name and ip of server and format the output and store in an output file. Please find the script below. #!/usr/bin/ksh cat $1 | tr "" "" | while read ip name do ERROR="$(nslookup $ip | grep can't | awk -F"... (2 Replies)
Discussion started by: Praveen P
2 Replies

9. Shell Programming and Scripting

How to correct this awk code without eval?

Hi everyone, The following piece of awk code works fine if I use eval builtin var='$1,$2' ps | eval "awk '{print $var}'" But when I try to knock off eval and use awk variable as substitute then I am not getting the expected result ps | awk -v v1=$var '{print v1}' # output is $1,$2 ps |... (4 Replies)
Discussion started by: royalibrahim
4 Replies

10. Shell Programming and Scripting

Same sed code prints(p) correct, but writtes(w) wrong output

Dear all, I am using sed as an alternative to grep in order to get a specific line from each of multiple files located in the same directory. I am using sed because it prints the lines in the correct order (unlike grep). When I write sed code that prints out the output I get it correct, but... (1 Reply)
Discussion started by: JaNaJaNa
1 Replies
voldiskadd(8)						      System Manager's Manual						     voldiskadd(8)

NAME
voldiskadd - Adds one or more disks for use with the Logical Storage Manager SYNOPSIS
/usr/sbin/voldiskadd disk-address-list DESCRIPTION
The voldiskadd utility sets up new disks that are added to the system after the initial system installation and configures the disks for use by the Logical Storage Manager. A valid disk label must exist on the disk before using the voldiskadd utility. One or more disks may be specified using a disk-address-list. Disk addresses in the list have the form dskn (for the entire disk) or dsknp (for a specific partition). When specifying multiple disks, use a space between entries. Disk address names relate directly to device names in the /dev/disk directory. For example, here are some valid voldiskadd disk-address-list specifications: # voldiskadd dsk1 # voldiskadd dsk2 dsk3a The file, /etc/vol/disks.exclude, may be used to exclude disks from use by voldiskadd. Each line of the file specifies the name of a disk to exclude (for example, dsk5). The voldiskadd utility prompts the user for a disk group name and disk media name for the disks. If a new disk group name is specified, that disk group is created for the new disks. If no disk group name is specified, the disks are left as unassigned replacement disks for future use. If an existing disk group name is specified, the user is prompted for whether the disks should be designated as spares for the disk group. If a disk is found to already contain non-Logical Storage Manager partitioning, the user is asked whether the disk should be encapsulated. Encapsulation turns each partition of the disk into a volume. A disk should be encapsulated if it contains file systems or data that should not be overwritten. If encapsulation is not desired for a disk, the disk can be initialized as a new disk for use by the Logical Storage Manager. For new disks, all space on the disk becomes free space in the disk's disk group. Context-sensitive help is available at every prompt by typing ?. Also, a list option can be used to get information on available target disks for an operation. The voldiskadd utility supports the following general classes of actions: Initializing a disk with reserved regions and partitions. Disk initialization is performed by calling voldisksetup command. Adding a disk to an existing disk group. This operation can be performed independently of the initialization of the disk drive to add a disk's storage space to a disk group's free space pool. The volassist command may subsequently allocate from that free space. The disk can also be added as a hot spare device. Creating new disk groups in which to import new disks. If no disk group exists for importing disks, the option of creating the disk group is offered. Encapsulating disks that have exist- ing contents. This is the default action for disks that do not have a valid, existing Logical Storage Manager private region, but that do have a disk label. Encapsulation is performed by calling volencap. Reconnecting a drive that was temporarily inaccessible. This situation is detected automatically, by noting that the specified drive has a disk ID that matches a disk media record with no currently associated physical disk. After reconnection, any stale plexes referring the disk are reattached, and any stopped volumes referring the disk are restarted. This reattach action is performed by calling the volrecover script. ERRORS
You may receive the following messages when using the voldiskadd command: Initialization of disk device special-device failed. Error: special-device or an overlapping partition is open. This message indicates that the partition you specified or an overlapping partition on the disk is actively in use. The partition could be a mounted UFS or AdvFS filesystem, initialized as an LSM disk or used as a swap device. special-device is marked in use for fstype in the disklabel. If you continue with the operation you can possibly destroy existing data. Would you like to continue?? [y,n,q,?] (default: n) This message indicates that the fstype of a partition or an overlapping partition is set in the disk label. The voldiskadd command prints this message to warn that a disk partition may have valid data which could be destroyed. If you are sure that the disk partition does not have valid data and that the partition can be added to LSM, you can ignore the warning message by entering y at the prompt. The voldiskadd command will proceed to initialize the disk partition and add it to LSM. FILES
A list of disks to exclude from use by voldiskadd. SEE ALSO
disklabel(8), volassist(8), voldisk(8), voldiskadm(8), voldisksetup(8), voldg(8), volintro(8) voldiskadd(8)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy