Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 13:36
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 136
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, 14:52
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Posts: 1,646
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
Data Warehousing on System z
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 12-06-07, 03:05
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
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, 17:50
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 136
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

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