Sponsored Content
Full Discussion: Execute command from awk
Top Forums Shell Programming and Scripting Execute command from awk Post 302641761 by neutronscott on Wednesday 16th of May 2012 01:18:34 PM
Old 05-16-2012
I created a fake "ioscan" which displays output like yours. the script is entirely awk. it'd probably be done better in shell, but i'm not certain which that is.

Code:
#!/usr/bin/awk -f
BEGIN {
        listcmd = "ioscan -fuNC disk"
        while ((listcmd | getline) > 0) {
                if ($1 != "disk")
                        continue
                wwidcmd="ioscan -P wwid -N -H " $3
                while ((wwidcmd | getline wwidline) > 0) {
                        if (wwidline !~ /^disk/)
                                continue
                        n=split(wwidline, a, /[[:space:]]*/)
                        if (a[3] == $3) print $0,a[4]
                }
                close(wwidcmd)
        }
}

produces output like this:
Code:
[mute@geek ~]$ ./script
disk      3  64000/0xfa00/0x0   esdisk   CLAIMED     DEVICE       HP      DG072A9BB7 0xd9ef341e08df0449ab6e28a6698b8ed1
disk      4  64000/0xfa00/0x1   esdisk   CLAIMED     DEVICE       HP      DG072A8B54 0xa3a7d748a36dfe2838c22cf71e79b25f
disk      5  64000/0xfa00/0x2   esdisk   CLAIMED     DEVICE       HP      DG072A8B54 0xeb955194471d1b877293b54ba7c12807
disk      7  64000/0xfa00/0x3   esdisk   CLAIMED     DEVICE       TEAC    DVD-ROM DW-224EV 0x17ed66ede9042c52d6570e66ea8c4112
disk     19  64000/0xfa00/0x9   esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x0e90354e6c63d4b66a9fe1e8191cd0d5
disk     20  64000/0xfa00/0xa   esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x35c07d3d928df2c0196e46a6296c8768
disk     21  64000/0xfa00/0xb   esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x2b6c01e7a6591d730234fd03c909d943
disk     22  64000/0xfa00/0xc   esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0xb403a1eb43fe26e4c5eadfc366554f29
disk     25  64000/0xfa00/0xd   esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x0b4a30a946bdcc35812f341d52577148
disk     34  64000/0xfa00/0x10  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0x83c9c360f1dd2b200c26d997bc5d19b6
disk     35  64000/0xfa00/0x11  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0xa33398f2469a04d6e6666696c9494569
disk     41  64000/0xfa00/0x12  esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x71db7f9609f641977acc1c3efa74fa19
disk     42  64000/0xfa00/0x13  esdisk   CLAIMED     DEVICE       EMC     SYMMETRIX 0x0813fa24f883561fee832cbafd13ae41
disk     47  64000/0xfa00/0x19  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0x31f43321710280c06969f2bf7092f452
disk     48  64000/0xfa00/0x1a  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0xf42a447b64f431b99d7fe59f65f71bc7
disk     49  64000/0xfa00/0x1b  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0x0e35417912095526b85ff927eeb3051d
disk     50  64000/0xfa00/0x1c  esdisk   CLAIMED     DEVICE       DGC     CX500WDR5 0x9e5630af99c9c6441083ed4b152e8210

---------- Post updated at 01:18 PM ---------- Previous update was at 01:09 PM ----------

Ya know ioscan can probably be made to output all of this but I cannot find a proper manual page for it. I'm guessing here but also hoping -P could take multiple options so that you can have it display all the fields you want instead of just wwid ...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How does this command execute?

Can somebody give me the explanation for this command line: ps>newfile<infile wc -l ? I am totally confused with the order of its execution.. :confused: Thanx, Saneesh Joseph. (3 Replies)
Discussion started by: saneeshjose
3 Replies

2. UNIX for Dummies Questions & Answers

Plz Help : How to use write command to execute command on some other terminal

Hi Group , I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages. - i m writing >write user-id ! ls o ctrl-d inspite of executing the command ls,other terminal shows ! ls. Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies

3. Shell Programming and Scripting

awk and execute command ???

If I have a flat file date.txt separate by a tab date1 date2 count 20060226 20060225 2 20060227 20060226 2 20060228 20060227 5 20060314 20060228 2 20060315 20060314 1 If $3 (count) is 5 then execute the script testit.ksh with... (13 Replies)
Discussion started by: sabercats
13 Replies

4. Shell Programming and Scripting

How to build a command into a string rather than execute the command

I'm trying to populate a command line into a variable. It appears to be executing, instead. Here's an example: mycmd='' if ...; then $mycmd='sudo ' fi $mycmd=$mycmd 'sed -i prev s/aaa/bbb/' $myfile res=`$mycmd` (I'm also not sure of the best way to execute the command from the... (1 Reply)
Discussion started by: littlejon
1 Replies

5. UNIX for Dummies Questions & Answers

how to execute an command this way

How to make it works this way? echo dir1\/*.txt ; echo dir1\/*.html | xargs wc -l dir1/*.txt wc: dir1/*.html: No such file or directory what i'm trying to do it to "wc dir1/*.txt" and "wc dir1/*.html" (2 Replies)
Discussion started by: Bornay6ah
2 Replies

6. Shell Programming and Scripting

awk and execute

Hi All, I need this to execute and not just print on Red Hat ent 4 bash shell. cat /etc/passwd|grep db2 | awk -F":" '{print "cat /etc/group | grep ",$4}' Output: cat /etc/group | grep 1000 (I don't want this to print but execute) Thanks for any comment you may add. (2 Replies)
Discussion started by: itik
2 Replies

7. Shell Programming and Scripting

Need help to execute command

HI, I have a directory called input directory called "input", The "input" directory contains file names (file1,file2,file3,file4), I want to write a command so that it will display all the file names with comma separated. Desired output: file1,file2,file3 so on.... Regards Akshay... (2 Replies)
Discussion started by: akshu.agni
2 Replies

8. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

9. Shell Programming and Scripting

How to execute a command on each line of output from another command?

Hello :) new to bash not to programming. I have an on-going need to change the owning group on sets of files and directories from the one they were created with or changed to on update to the one they need to have going forward. find {target_root} -group wrong_group gets me a newline... (4 Replies)
Discussion started by: naftali
4 Replies

10. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
vxdmp(7)						 Miscellaneous Information Manual						  vxdmp(7)

NAME
vxdmp - Veritas Volume Manager multipathing disk devices DESCRIPTION
Multipathed disk devices in Veritas Volume Manager (VxVM) represent virtual devices with one or more physical access paths to a physical disk. The Multipathing feature provides disk access reliability by dynamically switching to another physical path if there is a path fail- ure. Every disk that is visible to VxVM is represented by a multipath device node in the /dev/vx/dmp and /dev/vx/rdmp directories for block type and character type interfaces. A simple disk is represented by a multipath device having one physical path, whereas a disk that is part of a multiported disk array is represented by a multipath device with many device access paths depending upon the type of the disk array. VxVM uses standard disk device naming conventions to name multipath devices. For example, if there is a disk device with two physical access paths such as c1t0d0 and c2t0d0, the multipathing device node for this particular disk is created under /dev/vx/dmp and /dev/vx/rdmp as c1t0d0 or c2t0d0. To provide multipathing, VxVM maintains an internal database of all the multipathed devices detected by the system and their respective paths. The database is created at system boot time. When disks are added or removed from the system, VxVM provides support to reconfigure the multipath device database to reflect new states of the hardware, while the system is online. To reconfigure the DMP database, run ioscan followed by insf, and then invoke vxdctl enable (see vxdctl(1M)). The various access paths to a multipathed device can be seen by using a vxdisk command (see vxdisk(1M)). These commands open the multi- pathing configuration device /dev/vx/dmpconfig to obtain the required information about the various paths to a multipathed device and their states. VxVM also provides the facility to enable or disable a disk controller. This feature can be used to stop all I/Os through a particular con- troller to perform maintenance operations on it. Use the vxdmpadm command to do this and also perform other operations on the multipath device database. VxVM can provide notification about events that occur in the DMP database due to a change in hardware. See the vxnotify(1M) man page for more information. VxVM is capable of multipathing both Active/Active and Active/Passive disk arrays. FILES
/dev/vx/dmp Multipathing block devices. /dev/vx/rdmp Multipathing character devices. SEE ALSO
ioctl(2), vxdctl(1M), vxdisk(1M), vxdmpadm(1M), vxnotify(1M) VxVM 5.0.31.1 24 Mar 2008 vxdmp(7)
All times are GMT -4. The time now is 01:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy