1823228 Members
3597 Online
109648 Solutions
New Discussion юеВ

pvchange -t script

 
SOLVED
Go to solution
okcunix
Advisor

pvchange -t script

Need to change the timeout value on a large number of pv's. Did a "strings /etc/lvmtab" > /tmp/outputfile. Now I'd like to write a simple script to do a "pvchange -t 90" for every /dev/dsk/###### in /tmp/outputfile. Something along:
for i in 'cat /tmp/outputfile'
do
pvchange -t 90 /dev/dsk/######
done

But can't get the syntax down correctly. Appreciate any help.
12 REPLIES 12
hpuxrox
Respected Contributor

Re: pvchange -t script

for i in 'cat /tmp/outputfile'
do

pvchange -t 90 /dev/dsk/$i

done
Jeff Schussele
Honored Contributor

Re: pvchange -t script

Hi,

Copuple of things:

1) You'll need to strip the vg names & any non device entries in that output file.

2) Use the var in that loop
pvchange -t 90 $i

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sanjay_6
Honored Contributor

Re: pvchange -t script

try,

strings /etc/lvmtab |grep "/dev/dsk" > /tmp/outputfile

for i in `cat /tmp/outputfile`
do
pvchange -t 90 $i
done

Hope this helps.

Regds

Pete Randall
Outstanding Contributor

Re: pvchange -t script

First, rebuild your output file with this:

strings /etc/lvmtab |grep "/dev/dsk" |awk '{ print $1 } > /tmp/outputfile'

Then, do

for i in 'cat /tmp/outputfile'
do
pvchange -t 90 /dev/dsk/$i
done


Pete



Pete
okcunix
Advisor

Re: pvchange -t script

OK, tried this script:

for i in 'cat /tmp/pvchange'
do
pvchange -t 90 /dev/dsk/$i
done

Output was:
root# /usr/local/scripts/pvchange
Usage: pvchange
[-A Autobackup]
[-s] |
{[-S Autoswitch] [-x Extensibility] [-t IOTimeout] [-z SparePV]}
PhysicalVolumePath
"/tmp/pvchange": Too many arguments

/tmp/pvchange has 2 lines=
c#t#d#
c#t#d#
hpuxrox
Respected Contributor

Re: pvchange -t script

Try,

for i in 'cat /tmp/pvchange'
do
pvchange -t 90 /dev/dsk/"$i"
done

Sorry, not on a system to test it on.
okcunix
Advisor

Re: pvchange -t script

Yates,
Tried that change, it generated this error mesg:
"PhysicalVolumePath": must be a block special file.
hpuxrox
Respected Contributor

Re: pvchange -t script

use ,

/dev/rdsk/"$i"

for raw device
okcunix
Advisor

Re: pvchange -t script

Yates,
Nope, changing to rdsk didn't work either, same resulting error mesg:
"PhysicalVolumePath": must be a block special file.

Thanks for the help, I'm considering just running the command line on each pv.
hpuxrox
Respected Contributor

Re: pvchange -t script

A useful tip when debuging scripts is to put

#! /bin/ksh -x

that will print everything out line by line while excuting
Jeff Schussele
Honored Contributor
Solution

Re: pvchange -t script

Hi,

Your file will *already* contain
/dev/dsk/cXtYdZ
so all you'll need is $i

for i in $(cat /tmp/outputfile)
do
pvchange -t 90 $i
done

That should work for you IF you get the vg names & any arbitrary strings produced by the strings /etc/lvmtab command.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
okcunix
Advisor

Re: pvchange -t script

Jeff,

That did it. Thanks.