- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 08:13 AM
04-22-2009 08:13 AM
Super novice at scripting looking for a little guidance. Trying to figure out how to get the lun wwn and first device file for the lun with awk. This is is what I get when I run the following command.
sudo autopath display | egrep -i 'lun wwn |/dev/dsk' | awk '{print $0}'
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0775-0000
/dev/dsk/c19t0d6 Active
/dev/dsk/c21t0d6 Active
/dev/dsk/c23t0d6 Active
/dev/dsk/c25t0d6 Active
/dev/dsk/c27t0d6 Active
/dev/dsk/c29t0d6 Active
/dev/dsk/c31t0d6 Active
/dev/dsk/c33t0d6 Active
How can I pull just the lun wwn and first device file ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 08:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 08:31 AM
04-22-2009 08:31 AM
Re: Help with script
Actually, since I can't tell from your data whether or not 'autopath display' outputs more than that which you have shown, it would be better to do:
# sudo autopath display | awk '/^Lun WWN/ {LINE=$0;getline;LINE=LINE" "$1};END{print LINE}'
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0775-0000 /dev/dsk/c19t0d6
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 10:15 AM
04-22-2009 10:15 AM
Re: Help with script
Wasn't sure if all the line information was needed. Here's a full line section for a single lun.
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0737-0000
Virtual Device File : /hpap/dsk/hpap16
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d1 Active
/dev/dsk/c21t0d1 Active
/dev/dsk/c23t0d1 Active
/dev/dsk/c25t0d1 Active
/dev/dsk/c27t0d1 Active
/dev/dsk/c29t0d1 Active
/dev/dsk/c31t0d1 Active
/dev/dsk/c33t0d1 Active
==================================================================
I ran both commands, the first one just returns the dotted lines, and the second one just comes back to command prompt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 10:39 AM
04-22-2009 10:39 AM
Re: Help with script
...and that's a good reason to provide not only the output you want but to offer the raw _input_. Try this:
# sudo autopath display | awk '/^Lun WWN/ {LINE=$0};/^\/dev/ {LINE=LINE" "$1;print LINE;exit}'
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0737-0000 /dev/dsk/c19t0d1
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2009 08:59 PM
04-22-2009 08:59 PM
Re: Help with script
So then you do not want the exit, but you do want to stop printing after a first dev line.
Try this for an awk command:
awk '/^Lun WWN/ {LINE=$0};/^\/dev/&&LINE {print LINE, $1;LINE=""}'
So if the scripts see a line starting with 'Lun', then that line is remember in variable line.
Next, if a line starts with 'dev' AND there is something true in that variable LINE, then print LINE and the first field, and clear LINE making it false.
Enjoy,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2009 06:54 AM
04-23-2009 06:54 AM
Re: Help with script
I'm trying to get it to return the Lun WWN and the first device name. Here's the entire list set of luns from autopath display. I would like to just pull the Lun WWN and the first device name for each lun.
sudo autopath display
==================================================================
HPswsp Version : A.3.0F.02F.02F
==================================================================
Auto Discover : ON
==================================================================
Array Type : EVA-AA
Array WWN : 5000-1FE1-5010-64D0
Read Optimize : ON
Path Verification Period : 00:10
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-074E-0000
Virtual Device File : /hpap/dsk/hpap11
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d2 Active
/dev/dsk/c21t0d2 Active
/dev/dsk/c23t0d2 Active
/dev/dsk/c25t0d2 Active
/dev/dsk/c27t0d2 Active
/dev/dsk/c29t0d2 Active
/dev/dsk/c31t0d2 Active
/dev/dsk/c33t0d2 Active
==================================================================
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0751-0000
Virtual Device File : /hpap/dsk/hpap12
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d3 Active
/dev/dsk/c21t0d3 Active
/dev/dsk/c23t0d3 Active
/dev/dsk/c25t0d3 Active
/dev/dsk/c27t0d3 Active
/dev/dsk/c29t0d3 Active
/dev/dsk/c31t0d3 Active
/dev/dsk/c33t0d3 Active
==================================================================
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0758-0000
Virtual Device File : /hpap/dsk/hpap13
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d4 Active
/dev/dsk/c21t0d4 Active
/dev/dsk/c23t0d4 Active
/dev/dsk/c25t0d4 Active
/dev/dsk/c27t0d4 Active
/dev/dsk/c29t0d4 Active
/dev/dsk/c31t0d4 Active
/dev/dsk/c33t0d4 Active
==================================================================
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-075B-0000
Virtual Device File : /hpap/dsk/hpap14
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d5 Active
/dev/dsk/c21t0d5 Active
/dev/dsk/c23t0d5 Active
/dev/dsk/c25t0d5 Active
/dev/dsk/c27t0d5 Active
/dev/dsk/c29t0d5 Active
/dev/dsk/c31t0d5 Active
/dev/dsk/c33t0d5 Active
==================================================================
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0775-0000
Virtual Device File : /hpap/dsk/hpap15
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d6 Active
/dev/dsk/c21t0d6 Active
/dev/dsk/c23t0d6 Active
/dev/dsk/c25t0d6 Active
/dev/dsk/c27t0d6 Active
/dev/dsk/c29t0d6 Active
/dev/dsk/c31t0d6 Active
/dev/dsk/c33t0d6 Active
==================================================================
==================================================================
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0737-0000
Virtual Device File : /hpap/dsk/hpap16
Load Balancing Policy : No Load Balancing
Lun Timeout : Infinite Retry (-1)
==================================================================
Device Path Status
==================================================================
/dev/dsk/c19t0d1 Active
/dev/dsk/c21t0d1 Active
/dev/dsk/c23t0d1 Active
/dev/dsk/c25t0d1 Active
/dev/dsk/c27t0d1 Active
/dev/dsk/c29t0d1 Active
/dev/dsk/c31t0d1 Active
/dev/dsk/c33t0d1 Active
==================================================================
==================================================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2009 07:04 AM
04-23-2009 07:04 AM
Re: Help with script
It looks to me like Hein's variation returns what you want. Copying and pasting Hein's code and running it with your most recent input as posted gave me:
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-074E-0000 /dev/dsk/c19t0d2
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0751-0000 /dev/dsk/c19t0d3
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0758-0000 /dev/dsk/c19t0d4
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-075B-0000 /dev/dsk/c19t0d5
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0775-0000 /dev/dsk/c19t0d6
Lun WWN : 6005-08B4-0006-A7DB-0000-E000-0737-0000 /dev/dsk/c19t0d1
Isn't this what you want?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2009 07:15 AM
04-23-2009 07:15 AM
Re: Help with script
Yes, thats exactly what I want it to do. I am copying and pasting the exact syntax, but for some reason its not working for me. I am not sure why its not working for me. Guess I'll keep playing around with it till I can get it to work.
Thanks for your help.
G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2009 07:37 AM
04-23-2009 07:37 AM
Re: Help with script
One way you would _not_ the correct output is if the target strings were preceeded by whitespace. Remember that our solutions anchored ('^') things to the beginning of a line:
/^Lun WWN/
...and...
/^\/dev/
mean that the character sequences only match if they are the first characters on a line.
I would examine your output thusly:
# sudo autopath display | cat -etv
You could be less rigorous by doing:
# awk '/Lun WWN/ {LINE=$0};/\/dev/ ...
...or better (if whitespace preceeding is allowed):
# awk '/[[:space:]]*Lun WWN/ {LINE=$0};/[[:space:]]*\/dev/ && LINE {print LINE, $1;LINE=""}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2009 07:54 AM
04-23-2009 07:54 AM