Bug 487037 - Output from vgdisplay is not going to stdout when the volume group doesn't exist.
Summary: Output from vgdisplay is not going to stdout when the volume group doesn't ex...
Keywords:
Status: CLOSED DUPLICATE of bug 470560
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: lvm2
Version: 5.3
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Milan Broz
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-02-23 19:19 UTC by Darryl L. Pierce
Modified: 2015-06-22 00:06 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-02-24 09:24:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Darryl L. Pierce 2009-02-23 19:19:33 UTC
Description of problem:
Within a script I attempt to capture the output of "vgdisplay HostVG" and check it for the phrase "not found" in order to verify the volume group exists. I used the following snippet:

verify=$(vgdisplay HostVG)

When the volume group is present then $verify contains the output. However, when the volume group does not exist then $verify is empty and all output is sent solely to the console.

Version-Release number of selected component (if applicable):
lvm2-2.02.40-6.el5.x86_64

How reproducible:
Every time.

Steps to Reproduce:
1. attempt to assign to a variable the output for vgdisplay on a non-existent volume group
  
Actual results:
The variable is an empty string.

Expected results:
The output from the vgdisplay command.

Additional info:
Additionally, the return code for vgdisplay is 0. This may not be an error condition, but it would make scripting run better if we could check the return code to see if the volume group existed.

Comment 1 Milan Broz 2009-02-24 09:24:07 UTC
vgdisplay status  bug is fixed in upstream lvm2 (2.02.43) and will be in RHEL5.4
Changelog:
 Exit with non-zero status from vgdisplay if couldn't show any requested VG.

Better use "vgs" command here, status is correct here already:
# vgs x; echo $?
  Volume group "x" not found
5
# vgdisplay x; echo $?
  Volume group "x" not found
0

Error messages are printed to stderr now by default, so if you need its output, sipmply redirect it:

output=$(vgs name 2>&1)

*** This bug has been marked as a duplicate of bug 470560 ***


Note You need to log in before you can comment on or make changes to this bug.