1752793 Members
6186 Online
108789 Solutions
New Discussion юеВ

Re: again script issue

 
SOLVED
Go to solution
himacs
Super Advisor

again script issue

Hi Admins,

M preparing a shift which gives VG details with free space etc.

In some servers some VGs are deactivated.

If i run my script m getting correct output to a file..but without the error message for deactivated VGs.The same error message is displaying after i run the script but not in output file.

$ ./freecalc
vgdisplay: Volume group not activated.
vgdisplay: Cannot display volume group "/dev/vgtest1".
$ more /home/uxgsmc/disk.out

/dev/vg00 has total 2 disks
/dev/dsk/c2t0d0s2
/dev/dsk/c2t2d0s2
Used space is 71568 MB
Free space is 66608 MB

I want to include those message in output file..

Plz help on this


regards
himacs
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: again script issue

Hi Himacs:

All good Unix code uses STDERR (FD #2) to report errors and STDOUT (FD # 1) for "standard", normal output.

Thus, simply do:

# vgdisplay > myfile 2>&1

...which redirects STDOUT to 'myfile' and redirects STDERR to the same place as STDOUT which now is 'myfile'.

Regards!

...JRF...

himacs
Super Advisor

Re: again script issue

Hi JRF,

Yes i got it..

The same way i did its worked..

Regards!!!
himacs