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 > read from paramter file before running a script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-07, 12:36
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
Cool 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
Reply With Quote
  #2 (permalink)  
Old 12-05-07, 13:52
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #3 (permalink)  
Old 12-06-07, 02:05
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
for param5 in `cat param5_list.txt` # space,tab,new line delimited
do
gen_file.ksh param1 param2 param3 param4 $param5
done
Reply With Quote
  #4 (permalink)  
Old 12-06-07, 16:50
saccskiz saccskiz is offline
Registered User
 
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
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