1847027 Members
4774 Online
110258 Solutions
New Discussion

Basic script issue

 
SOLVED
Go to solution
frederick hannah
Super Advisor

Basic script issue

I am trying to write a simple script that will read tape media located in a file and run a command against each tape in the file. Of course I am learning as I go along, but can any help me? FYI: I am on an 11.11 platform.
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Basic script issue

Hi:

For the sake of the example, assume that the input file has whitespace-delimited fields of a tapename and a tape number, like:

# cat ./inputlist
full_080603 789
increm_080604 900
increm_080605 877

...then, something like:

#!/usr/bin/sh
while read NAME SERIAL X
do
echo "${NAME} available"
done < inputlist

...will work...

The 'X' field will gobble up any fields that follow the 'SERIAL' field if is should exist. If the extent of what you want is just the 'NAME' then just write:

while read NAME X

...for the same reason.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: Basic script issue

I'm guessing from your description that a simple for loop might suffice. Something like:

for MEDIA in `cat medialist`
do
tar -xvf $MEDIA
done

I used tar since you didn't specify.


Pete

Pete
frederick hannah
Super Advisor

Re: Basic script issue

thanks for quick replies, but neither answer seems to work. I have a file consisting of vsn that need to be read into the following program (example):

xxxxx xxxxx

The program can read only tape at a time. I know the answer is simple, but it escapes me.
Steven Schweda
Honored Contributor

Re: Basic script issue

It's possible that you know what you're
talking about, but it's far from clear to me.
I freely admit that my psychic powers are
weak.

Perhaps you could show what's in your "file
consisting of vsn", and what the resulting
command(s) you'd like generate would look
like. Given some actual information, you can
almost certainly find someone who can write
a script to do what you want. Given no
useful information, all you'll get will be a
lot of guesswork, which may be of limited
value.
Dennis Handly
Acclaimed Contributor

Re: Basic script issue

>I have a file consisting of vsn:
xxxxx xxxxx

You need to make this simpler. Is it:
XXX VVVV YYY

Where you want to just extract the VVVV field?
If so, you change JRF's script to:
while read X VSN X; do
echo "${VSN} available"
done < inputlist
frederick hannah
Super Advisor

Re: Basic script issue

In a nutshell, the file is structured as follows:

000001
000002
000003

A tower list of vsn's only. I am looking for a script that will read those vsn(s) into the following command:

bpmedia -movedb -ev -oldsever

James R. Ferguson
Acclaimed Contributor
Solution

Re: Basic script issue

Hi (again):

I already provided what you need:

# cat vsnfile
000001
000002
000003

#!/usr/bin/sh
while read VSN
do
bpmedia -movedb -ev ${VSN} -oldsever
done < vsnfile

...it doesn't get any harder.

Regards!

...JRF...
frederick hannah
Super Advisor

Re: Basic script issue

thanks for the assist
frederick hannah
Super Advisor

Re: Basic script issue

It works. I appreciate the support