cancel
Showing results for 
Search instead for 
Did you mean: 

script for vmchange -d to multiple tapes

pylej
Level 4

Hello,

I would like to write a small shell script or use perl to be able to change the description of mulitple tape from a flat file list of tapes. So something that would do the same as ./vmchange -d "test" -m /tmp/tape_list.txt

So it would be some kind of loop, but I just don't know how to do it.
Any ideas?

Thanks
Jim

1 ACCEPTED SOLUTION

Accepted Solutions

Andy_Welburn
Level 6
The single quotes '  '  behave similarly to double quotes "  ", but much differently from the action quotes `  ` !! ;)

View solution in original post

10 REPLIES 10

Will_Restore
Level 6

while read ID
do
  /usr/openv/volmgr/bin/vmchange -d "test" -m $ID
done


now run it :
./yourscriptname <  /tmp/tape_list.txt

Andy_Welburn
Level 6
for TAPE in `cat /tmp/tape_list.txt`
do
vmchange -d "test" -m $TAPE
done

(presuming /tmp/tape_list.txt is a list of media ids
e.g.
100100
100104
100302
etc etc)

***EDIT***
But Bill beat me to it!!

stu52
Level 5
cat /tmp/tape_list.txt | xargs -i vmchange -d "test" -m {}


same tape_list as above....no script, just a one-liner on the command line

pylej
Level 4
Hi Gents,

Good stuff thanks, the one liner that stu provided works perfect

But I am having trouble with the for command, which is what I was tring to use before, it keeps giving me unrecognized option /tmp/tape_list.txt. I am tring to master some simple loops with Netbackup and I don't under why it is complaining.

Thank you very much!

J_H_Is_gone
Level 6
/tmp/tape_list.txt should the the location and file name of the file you put all the tape numbers in.

if you did not put the file in /tmp or if you did not call it tape_list.txt  then just change that to the correct path and file name of your list of tapes.

Andy_Welburn
Level 6
you will get that error if you try & use the command you initially posted, or if you did "for TAPE in /tmp/tape_list.txt" as it will read that entry as an input variable in and of itself, it will not read the contents of the file. You will need to use `cat /tmp/tape_list.txt` if you were trying my method.

Will_Restore
Level 6
that's very good too :)

pylej
Level 4
Hi Andy,

I know what I did wrong now, I was using ' instead of `  for the cat /tmp/tape_list.txt .  This has been very helpful for me, thanks alot to everyone who has posted.

Jim

Andy_Welburn
Level 6
The single quotes '  '  behave similarly to double quotes "  ", but much differently from the action quotes `  ` !! ;)

Stumpr2
Level 6
The trick to a successful loop is to first verify that the command syntax works outside of the loop.

.