cancel
Showing results for 
Search instead for 
Did you mean: 

script for vmchange -d to multiple tapes

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 Solution

Accepted Solutions
Accepted Solution!

That makes sense

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

View solution in original post

10 Replies

create this script


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


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

Simplest form for some such loop would be:

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!!

or even like this....

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

Hi Gents, Good stuff thanks,

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!

Where did you make your file?

/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.

@Jim. You haven't said exactly what you've tried, but

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.

oh

that's very good too :)

Hi Andy, I know what I did

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
Accepted Solution!

That makes sense

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

View solution in original post

loopy trick

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

.