11-18-2008
is that possible to keep statements in any loop??
Hi,
Actually i stored all validdisks in one array and corresponding partitions required for all individual disks in other array..
Example:
Validdisks[$diskcnt]=dsk2 dsk3 dsk5
ValidPartition[$Partitioncnt]=4 4 3
Now i have to create domain..
Domain creation can be done by below commands:
fs_setup -d /dev/disk/${Validdisks[0]}a -n ${cfsfailover_dmn} -m ${cfsfailover_mnt}"
addvol /dev/disk/${Validdisks[$diskcnt]}h ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}g ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}b ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}a ${cfsfailover_dmn}
But tricky is there in creating domain...
Lets go first with Validdisk[0] element:
============================
By checking the elements in ValidPartition[$Partitioncnt] array,i need to create.. Since first element of ValidPartition[0]=4 means (we have to use a,b,g,h)
Domain creation for one disk wil be as below:
fs_setup -d /dev/disk/${Validdisks[0]}a -n ${cfsfailover_dmn} -m ${cfsfailover_mnt}"
addvol /dev/disk/${Validdisks[$diskcnt]}b ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}g ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}h ${cfsfailover_dmn}
And lets go with second element of validdisk[1]
Now here By checking the elements in ValidPartition[1] here it has 4 so again domain creation for second disk must be as below:
addvol /dev/disk/${Validdisks[$diskcnt]}a ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}b ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}g ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}h ${cfsfailover_dmn}
And lets go with third element of Validdisk[2]
Now here By checking the elements in ValidPartition[2] here it has 3 so use a,b,g only
addvol /dev/disk/${Validdisks[$diskcnt]}a ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}b ${cfsfailover_dmn}
addvol /dev/disk/${Validdisks[$diskcnt]}g ${cfsfailover_dmn}
And note that, "
fs_setup -d /dev/disk/${Validdisks[0]}a -n ${cfsfailover_dmn} -m ${cfsfailover_mnt}"
that should be written only once for first disk.. Later on we have to use addvol statements...Could you please help me by doing this in KSH scripting..Is that possible to keep in for loop?? Please provide your inputs..Thanks,Mansa
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
how do i do an or in an if-then statement? i tried:
if ; then
bleh
fi
how???? (1 Reply)
Discussion started by: Blip
1 Replies
2. Shell Programming and Scripting
I had different problem scenarios with IF statement. Can any expert please enlighten me on the difference with these scenarios. Thank you.
1st Scenario:
testdate=`date +%Y%m`
test=`cat /var/log/database0.$testdate*.log | grep "Errors found during processing" | tail -10`
if
then
... (4 Replies)
Discussion started by: filthymonk
4 Replies
3. Shell Programming and Scripting
New to scripting in general, so patience plz. If I ask a stupid question or don't get it, I thank you for your kindness in advance.
That said, did a for i loops checks to see if a PB* file is there but I need to know two things before I copy the file.
I need to know if the file's create date... (2 Replies)
Discussion started by: xgringo
2 Replies
4. Shell Programming and Scripting
I am kind of new in Unix and i have to make a menu. I want to put an if statement in the menu. you should enter the filename and it goes to that file. How do i do this? (1 Reply)
Discussion started by: trob
1 Replies
5. UNIX for Dummies Questions & Answers
Hi, I am trying to write a for statement that will allow for the ps, who, finger, and date commands to run. Can anyone help? I use Putty. (22 Replies)
Discussion started by: lexydoll87
22 Replies
6. Shell Programming and Scripting
HI Unix Gurus,
I have a number of SELECT count(*) statements in an input file and I want to execute it using a shell script but one by one using loop in script....
How can I do this..... (7 Replies)
Discussion started by: ustechie
7 Replies
7. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers:
1) Use a while... (11 Replies)
Discussion started by: jjb1989
11 Replies
8. Shell Programming and Scripting
Hello. I am new here and new to scripting. I used to have a very basic script that worked for simple backup/restore of files. I have expanded it and well... I have ended up with a complete mess. It still backs up and restores but there is so many issues that stem from the many if statements I... (3 Replies)
Discussion started by: gameinn
3 Replies
9. Shell Programming and Scripting
Bash shell, variables i and rem are working fine in 2 separate for loops, but I'd like to consolidate them like this:
for && This gives syntax error on &&.
Thanks in advance for direction. (5 Replies)
Discussion started by: p1ne
5 Replies
10. Shell Programming and Scripting
Say I have a for loop that parse through a file....Say it look for the colors red and blue in sections of the file. Say it find red before it find blue in the file.
Say I have two if statements in the for loop
Something like if blue is found print blue is my favorite color is the first if... (7 Replies)
Discussion started by: scj2012
7 Replies
PARTX(8) System Administration PARTX(8)
NAME
partx - tell the kernel about the presence and numbering of on-disk partitions
SYNOPSIS
partx [-a|-d|-P|-r|-s|-u] [-t type] [-n M:N] [-] disk
partx [-a|-d|-P|-r|-s|-u] [-t type] partition [disk]
DESCRIPTION
Given a device or disk-image, partx tries to parse the partition table and list its contents. It can also tell the kernel to add or remove
partitions from its bookkeeping.
The disk argument is optional when a partition argument is provided. To force scanning a partition as if it were a whole disk (for example
to list nested subpartitions), use the argument "-" (hyphen-minus). For example:
partx --show - /dev/sda3
This will see sda3 as a whole-disk rather than as a partition.
partx is not an fdisk program - adding and removing partitions does not change the disk, it just tells the kernel about the presence and
numbering of on-disk partitions.
OPTIONS
-a, --add
Add the specified partitions, or read the disk and add all partitions.
-b, --bytes
Print the SIZE column in bytes rather than in human-readable format.
-d, --delete
Delete the specified partitions or all partitions.
-g, --noheadings
Do not print a header line with --show or --raw.
-l, --list
List the partitions. Note that all numbers are in 512-byte sectors. This output format is DEPRECATED in favour of --show. Do not
use it in newly written scripts.
-n, --nr M:N
Specify the range of partitions. For backward compatibility also the format M-N is supported. The range may contain negative num-
bers, for example --nr -1:-1 means the last partition, and --nr -2:-1 means the last two partitions. Supported range specifications
are:
M Specifies just one partition (e.g. --nr 3).
M: Specifies the lower limit only (e.g. --nr 2:).
:N Specifies the upper limit only (e.g. --nr :4).
M:N Specifies the lower and upper limits (e.g. --nr 2:4).
-o, --output list
Define the output columns to use for --show, --pairs and --raw output. If no output arrangement is specified, then a default set is
used. Use --help to get list of all supported columns. This option cannot be combined with the --add, --delete, --update or --list
options.
-P, --pairs
List the partitions using the KEY="value" format.
-r, --raw
List the partitions using the raw output format.
-s, --show
List the partitions. The output columns can be selected and rearranged with the --output option. All numbers (except SIZE) are in
512-byte sectors.
-t, --type type
Specify the partition table type.
--list-types
List supported partition types and exit.
-u, --update
Update the specified partitions.
-S, --sector-size size
Overwrite default sector size.
-v, --verbose
Verbose mode.
-V, --version
Display version information and exit.
-h, --help
Display help text and exit.
EXAMPLES
partx --show /dev/sdb3
partx --show --nr 3 /dev/sdb
partx --show /dev/sdb3 /dev/sdb
All three commands list partition 3 of /dev/sdb.
partx --show - /dev/sdb3
Lists all subpartitions on /dev/sdb3 (the device is used as whole-disk).
partx -o START -g --nr 5 /dev/sdb
Prints the start sector of partition 5 on /dev/sdb without header.
partx -o SECTORS,SIZE /dev/sda5 /dev/sda
Lists the length in sectors and human-readable size of partition 5 on /dev/sda.
partx --add --nr 3:5 /dev/sdd
Adds all available partitions from 3 to 5 (inclusive) on /dev/sdd.
partx -d --nr :-1 /dev/sdd
Removes the last partition on /dev/sdd.
SEE ALSO
addpart(8), delpart(8), fdisk(8), parted(8), partprobe(8)
AUTHORS
Davidlohr Bueso <dave@gnu.org>
Karel Zak <kzak@redhat.com>
The original version was written by Andries E. Brouwer <aeb@cwi.nl>.
ENVIRONMENT
LIBBLKID_DEBUG=all
enables libblkid debug output.
AVAILABILITY
The partx command is part of the util-linux package and is available from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils
/util-linux/>.
util-linux December 2014 PARTX(8)