reading the parameter from another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading the parameter from another file
# 1  
Old 12-19-2007
reading the parameter from another file

I have a script where 3 parametrs are passed to it and it creates the file for each site form a template. If i want to
get the 3rd parameter (which is the site) passed to the script to come from another file how I can change the script tp acheive it?

Here is my script:
Quote:
update.ksh 20071912 1 ind
what i have in the sciprt is simple sed commands.

I need the 3rd parameter to be read from the another file and run it recursively to create 20 different files.

The site file has 20 entries and hence it needs to create 20 files.

Can some body let mw know how i can do that?
# 2  
Old 12-19-2007
assuming '/path/to/siteFile' containts one 'site' per line.

Code:
#!/bin/ksh

for site in $(< /path/to/siteFile)
do
 update.ksh 20071912 1 "${site}"
done

# 3  
Old 12-19-2007
Vgresh,

Its not able to read the contents from site file and i am getting the below error:

update.ksh 20071912 1 ./

what i have in there is :

Quote:
for site in ./$(sites.txt)
do
update.ksh 20071912 1 "${site}"
done
# 4  
Old 12-19-2007
Vgresh,

Its able to read from the sites.txt but not able to run the script .

Its not able to execute the script with the site parameter replaced. can you let me know the reason

for site in $(/home/sravan/sites.txt)
do
update.ksh 20071912 1 "${site}"
done
# 5  
Old 12-19-2007
Vgresh,

I am getting the below error:


/home/sravan/sites.txt: jon: not found
/home/sravan/sites.txt[2]: ind: not found
/home/sravan/sites.txt[3]: bur: not found
/home/sravan/sites.txt[4]: lan: not found
/home/sravan/sites.txt[5]: viz: not found
/home/sravan/sites.txt[6]: vaz: not found
/home/sravan/sites.txt[7]: cha: not found
/home/sravan/sites.txt[8]: hon: not found
/home/sravan/sites.txt[9]: hcl: not found
/home/sravan/sites.txt[10]: ron: not found
/home/sravan/sites.txt[11]: rap: not found
/home/sravan/sites.txt[12]: jai: not found
/home/sravan/sites.txt[13]: can: not found
/home/sravan/sites.txt[14]: rom: not found
/home/sravan/sites.txt[15]: jon: not found
/home/sravan/sites.txt[16]: son: not found
/home/sravan/sites.txt[17]: pan: not found
/home/sravan/sites.txt[18]: cri: not found
/home/sravan/sites.txt[19]: ros: not found
/home/sravan/sites.txt[20]: pne: not found
# 6  
Old 12-19-2007
look at my original post:
Code:
#!/bin/ksh

for site in $(< /path/to/siteFile)
do
 update.ksh 20071912 1 "${site}"
done

# 7  
Old 12-19-2007
Thanks Vgresh!!!! Thats simply great.

can you let me know the significance of < here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To call Oracle procedure by reading parameter file in UNIX

hi Guys, is there a way to pass parameter into oracle store procedure by reading date range in file and increment accordingly. Something like this file.txt 01-JAN-2015 03-JAN-2015 sqlplus -s user/pwd@DB execute TEST( to_date( '01-JAN-2015, 'dd.mm.yyyy' ), to_date( '03-JAN-2015', ... (1 Reply)
Discussion started by: rohit_shinez
1 Replies

2. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

3. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

4. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

5. Shell Programming and Scripting

Help with reading parameter.

Hi,. I need a help with below strange behaviour. I use into script parameters as read A read B and my parameter B (password from Active directory) is changed by adding backslash to all characters (123456as; -> \1\2\3\4\5\6\a\s\;) and I use it as parameter into script. When I pass it to... (5 Replies)
Discussion started by: beckss
5 Replies

6. Shell Programming and Scripting

Reading a variable from parameter file

HI all, I have a parameter file with entries like $$Name =Abhinav $$CUTOFF_DATE = 11/11/2209 I am reading a variable from this file using a awk command like : var2=`awk -F"" "/CUTOFF_DATE/{f=$1;}{print f;}" InputFIleName` but facing an error like awk: cmd. line:1:... (3 Replies)
Discussion started by: abhinav192
3 Replies

7. UNIX for Dummies Questions & Answers

Reading from a file(passing the file as input parameter)

hi I have a shell script say primary.sh . There is a file called params my scenario is primary.sh should read all the values and echo it for example i should pass like $primary.sh params output would be Abc ... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

8. Shell Programming and Scripting

Getting the value from a parameter file

Hi I am nebie to Unix I have a prameter file which has semicolon seperated values which has the field STATUS_CODE;9000;1;1200;2000 The values are dynamic ie. it can be 1,2,3...any number How do i get all the values of this parameter into a variable Please if anyone can help me out on... (2 Replies)
Discussion started by: theeights
2 Replies

9. Shell Programming and Scripting

Reading a Parameter File

Hi, I need to read the parameters from a file and assign them to Global variables. I need to read a specific parameter value every time and pass it to the other script. Suppose i have a parameter file like PARAM.txt PAR1= VAL1 PAR2= VAL2 PAR3= VAL3 I want to read PAR2 file and in the... (1 Reply)
Discussion started by: Raamc
1 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question