- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- capture command output
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
07-15-2005 03:08 AM
07-15-2005 03:08 AM
Trying to capture the output of the cammand vgdisplay.
I am in a SG environment so not all VGs are active .
What I am doing
vgdisplay | awk '$0~"VG Name"{print substr($NF,6)}'
The VGs that are not active are echoing to screen. I cannot get them into $LOG file.
I have done 2>&1 but no luck.
Any ideas?
Solved! Go to Solution.
- Tags:
- redirect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 03:20 AM
07-15-2005 03:20 AM
Re: capture command output
ls /dev/*/group |cut -f3 -d"/"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 03:29 AM
07-15-2005 03:29 AM
Re: capture command output
Have you tried command grouping? I run a variation of your command on a regular basis and it works fine for me.
# { vgdisplay | awk '$0~"VG Name"'; } > out_file 2>&1
OR
# ( vgdisplay | awk '$0~"VG Name"' ) > out_file 2>&1
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 03:43 AM
07-15-2005 03:43 AM
Re: capture command output
I tried your command on my HP system and the only way I could get it to work was by command grouping and piping the output of your command into another awk construct. I'ave pasted the command that I ran on my system and it might be what you're looking for.
# { vgdisplay | awk '$0~"VG Name"' | awk -F"VG Name *" '{print $2}'; } > outfile 2>&1
OR
# ( vgdisplay | awk '$0~"VG Name"' | awk -F"VG Name *" '{print $2}' ) > outfile 2>&1
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 04:02 AM
07-15-2005 04:02 AM
Re: capture command output
vgdisplay 2>&1 |grep '/dev/' |cut -f3 -d'/' |cut -f1 -d'"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 04:15 AM
07-15-2005 04:15 AM
Re: capture command output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 04:45 AM
07-15-2005 04:45 AM
Re: capture command output
Tried the responses but what is getting to the $LOG file are the VGs that are active. And this is good.
What I see is the following:
vgdisplay: Volume group not activated.
vgdisplay: Cannot display volume group "/dev/vg1".
vgdisplay: Volume group not activated.
vgdisplay: Cannot display volume group "/dev/vg2".
I have tried pipes, script, the /dev/group entries, etc.
Those VGs that are cluster aware and are not presently active on a node, I cannot get into $LOG.
In my script, here is the line I am doing
VG_LIST=`vgdisplay | awk '$0~"VG Name"{print substr($NF,6)}'`
I have tried >/dev/null 2>&1 >> $LOG, piping through the 'tee' command, using the script function, etc...
No working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:00 AM
07-15-2005 05:00 AM
Solutionwhen I use your command I get this:
[root@pyrite] > VG_NAME=`vgdisplay | awk '$0~"VG Name"{print substr($NF,6)}'`
vgdisplay: Volume group not activated.
vgdisplay: Cannot display volume group "/dev/vgqdx".
[root@pyrite] > echo $VG_NAME
vg00 vg09 vg07 vg02 vg01 vg03 vg04 vg06 vg05
[root@pyrite] >
by changing it to search for the string "/dev/" I get this:
[root@pyrite] > VG_NAME=`vgdisplay 2>&1 |grep '/dev/' |cut -f3 -d'/' |cut -f1 -d'"'
[root@pyrite] > echo $VG_NAME
vgqdx vg00 vg09 vg07 vg02 vg01 vg03 vg04 vg06 vg05
[root@pyrite] >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:02 AM
07-15-2005 05:02 AM
Re: capture command output
I do need the "Volume Groupo not active" messages in the $LOG file as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:06 AM
07-15-2005 05:06 AM
Re: capture command output
I can not find a way to do it in one command but these two will do the trick:
vgdisplay 2>/tmp/err | grep "VG Name" | awk {'print $3'} |cut -d/ -f3 > /tmp/out
grep Cannot /tmp/err|cut -d/ -f3|cut -d\" -f1>>/tmp/out
hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:12 AM
07-15-2005 05:12 AM
Re: capture command output
ACT_VGs=`vgdisplay 2>&1 | awk '$0~"VG Name"{print substr($NF,6)}'`
INACT_VGs=`vgdisplay 2>&1 |grep '^vgdisplay:'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:17 AM
07-15-2005 05:17 AM
Re: capture command output
Mel and Alan. Got it.
Put the error handling before my pipes.
Many thanks to all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2005 05:38 AM
07-15-2005 05:38 AM
Re: capture command output
VG_LIST=`vgdisplay 2>>$LOG | awk '$0~"VG Name"{print substr($NF,6)}'`
Works like a champ. I get the inactive clustered VGs as well as the active ones in the $LOG file.