Operating System - HP-UX
1839713 Members
2689 Online
110153 Solutions
New Discussion

Re: Adding Data to an Existing File

 
Andrew Kaplan
Super Advisor

Adding Data to an Existing File

Hi there --

I am in the process of creating a script that will run the vgdisplay utility on each logical volume on our vg00 volume group and pipe it to a file. The file, in turn, will be e-mailed to the system administrator. I would like to have the information of all logical volumes generated to one file rather than separate ones. How would I go about having each logical volume added to a single file? Thanks.
A Journey In The Quest Of Knowledge
5 REPLIES 5
generic_1
Respected Contributor

Re: Adding Data to an Existing File

Hello
vgdisplay -v /dev/vg00 >> /tmp/file.out
vgdosplay -v /dev/vg01 >> /tmp/file.out
> will overwrite a file
>> appends to a file


If you were running a bunch of commands manually you can use script -a /tmp/file.out
to log all of your screen output.

you could even do a for loop script

for i in `cat /tmp/vglist`
do
vgdisplay -v /dev/vg$i >> /tmp/file.out
done


# now send file to yourself
cat /tmp/file.out |mailx -s "your subject" you@yourmail.com
In the vglist file you would put the volume groups you want your command ran against.
example in vglist file follows
01
02
03


and so on :)


Hope this was a helpful answer. The example should do exacly what you wanted.
Cheryl Griffin
Honored Contributor

Re: Adding Data to an Existing File

This Nickel script will do this for you as well as capture other system specific inforamtion. ftp://hprc.external.hp.com/sysadmin/inventory/nickel/

See Bill's reply which describes how he uses it http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=754241
"Downtime is a Crime."
Muthukumar_5
Honored Contributor

Re: Adding Data to an Existing File

You can send vgdisplay report as,

# vgdisplay -v /dev/vg00 | mailx -s "vgdisplay information for vg00 from `hostname`"

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Adding Data to an Existing File

You can send by volume group and logical volume information as,

(vgdisplay;lvdisplay `bdf | awk '/\/dev\/vg00/ { print $1 }'`) | mailx -s "vgdisplay, lvdisplay for vg00"

To send as a attachment,

(vgdisplay;lvdisplay `bdf | awk '/\/dev\/vg00/ { print $1 }'`) > /tmp/vg_lv_display.log

uuencode /tmp/vg_lv_display.log | mailx -s "vgdisplay, lvdisplay for vg00 `hostname`"

hth.
Easy to suggest when don't know about the problem!
Amit Agarwal_1
Trusted Contributor

Re: Adding Data to an Existing File

Jeff's answer would work fine. Just a simple addition I would like to see is to truncate the /tmp/file at the beginnign of script. This would ensure that previous data is erased.

$ cat script
> /tmp/file # this will truncate the file
for i in `cat /tmp/vglist`
.
.
.
done


-Amit