Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    4

    Question Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

  3. #3
    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 06:39.

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •