Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    143

    Cool Unanswered: read from paramter file before running a script

    I am on sun solaris 5.8

    I have a script gen_file.ksh that takes in 5 parameters... Like

    gen_file.ksh param1 param2 param3 param4 param5

    Is it possible for me to read another file, say param5_list.txt and read each line from that file
    and run the above script that many times(as the number of lines found in the param5_list.txt)

    In other words, if my param_list.txt has 3 different param5 values in 3 different lines like

    123
    456
    789

    I needed my script to run 3 times

    gen_file.ksh param1 param2 param3 param4 123
    gen_file.ksh param1 param2 param3 param4 456
    gen_file.ksh param1 param2 param3 param4 789

    Any pointers on how this can be done would be great. Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You can open "param_list.txt", loop over the entries and inside the loop you run your "gen_file.ksh" script. Simple shell variables should do the trick. Have you tried that? If so, where do you get stuck?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    for param5 in `cat param5_list.txt` # space,tab,new line delimited
    do
    gen_file.ksh param1 param2 param3 param4 $param5
    done

  4. #4
    Join Date
    Feb 2004
    Posts
    143
    Thanks folks.. it worked..(very similar to pdreyer's note)

    cat param5_list.txt | while read Line
    do
    genscript.ksh param1 param2 param3 param4 $Line
    done

Posting Permissions

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