Forum Discussion

pylej's avatar
pylej
Level 4
15 years ago

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

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

10 Replies


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


    now run it :
    ./yourscriptname <  /tmp/tape_list.txt
  • 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!!

  • 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, 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!
  • /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.
  • 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.
  • 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
  • The single quotes '  '  behave similarly to double quotes "  ", but much differently from the action quotes `  ` !! ;)
  • The trick to a successful loop is to first verify that the command syntax works outside of the loop.

    .