If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > argu pass from 1 file to another file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-04-03, 13:28
visvid visvid is offline
Registered User
 
Join Date: Jul 2003
Posts: 4
Question argu pass from 1 file to another file

Question:

How do i pass arguments from one file to another and then execute a cmd ?

Scenario

2 files , file one is called solarisdisks and the other is called veritaslist

solarisdisk is :

c3t30d11
c3t30d12
c3t30d13
c3t30d14
c3t61d11
c3t61d12
c3t61d13
c3t61d14

veritaslist

hd3_3_11
hd3_3_12
hd3_3_13
hd3_3_14
hd3_61_11
hd3_61_12
hd3_61_13
hd3_61_14


what I want to do is once i have vxdg init <dgname> diskname=c?t?d?

I want to run is a command that will basically do

vxdg -g <dgname> adddisk <veritaslist>= <solarisdisk>


Cheers

visvid
Reply With Quote
  #2 (permalink)  
Old 08-04-03, 15:55
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

You could try arrays, something like:


VL=$(cat veritaslist)
set -A SL $(cat solarisdisk)
i=0
for vf in VL
do
vxdg -g <dgname> adddisk $vf = ${SL[i]}
(( i += 1 ))
done
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 08-05-03, 05:32
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
A simple way to read data in from a file is to use the 'read' command.

while read yourVar
do
some commands with $yourVar
done < yourFile

Obviously, you could nest this...

while read yourVar1
do
while read yourVar2
do
some commands with $yourVar1 $yourVar2
done < yourFile2
done < yourFile1


Alternatively, if you're trying to work with 2 files simultaneously, do something like this...

paste -d"|" file1 file2 | while IFS="|" read file1Var file2Var
do
some commands with $file1var
some commands with $file2var
done

The -d flag and the setting of IFS is just to ensure that the line read from file 2 is always $fileVar2 as the files may be different lengths.

Last edited by Damian Ibbotson; 08-05-03 at 05:39.
Reply With Quote
  #4 (permalink)  
Old 08-05-03, 10:20
visvid visvid is offline
Registered User
 
Join Date: Jul 2003
Posts: 4
vxdg init stdg01 hd3_3_11=c3t30d11
paste -d"|" vertiasdisks sundisks | while IFS="|" read var1 var2
do
vxdg -g stdg01 adddisk $var1=$var2
done


this one has worked great for this cheers

visvid
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On