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:

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?

assuming '/path/to/siteFile' containts one 'site' per line.

#!/bin/ksh

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

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 :

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

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

look at my original post:

#!/bin/ksh

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

Thanks Vgresh!!!! Thats simply great.

can you let me know the significance of < here.

cat file | xargs -n 1 update.ksh 20071912 1

from 'man ksh'

       < file standard  input  is  redirected  from  file, which is opened for
              reading.

Thanks Vgresh.

But I want to know how $( < ) is decoded to read the file contents? What is the significance of $( here?
cant we just give

for site in /home/sites.txt
do
update.ksh 20071912 1 "${site}"
done

no, you cannot have that. The 'for i in <list>' where the list is 'list' of "words". Here's the quote from 'man ksh':

       for name [ in word ... term ] do list done
              where term is either a newline or a ;.  For  each  word  in  the
              specified  word  list, the parameter name is set to the word and
              list is executed.  If in is not used to specify a word list, the
              positional  parameters ("$1", "$2", etc.) are used instead.  For
              historical reasons, open and close braces may be used instead of
              do  and  done (e.g., for i; { echo $i; }).  The exit status of a
              for statement is the last exit status of list; if list is  never
              executed, the exit status is zero.

'$( command )' is ksh's way to invoke command 'command' in the subshell.
In your case the command is '< filename'. What this does is redirects the content of 'filename' into the stdin of the calling process - your case simply lists the content of the filename as a list of 'words' for the 'for' loop to iterate through.

For example:

#!/bin/ksh
$ echo 'fred' > foo
$ echo $(<foo)
fred

vgresh,

I made a samll adjustment to the script like below, but was not succesful in creating files for the sites for the day the script is run. can you let me know whats wrong here?

export NEW_DT=`date +%m%d%Y`
export NEW_DT=$1

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

First, pls use vB Codes when posting code and/or quoting something.
Secondly, I don't understand what you're trying to do?
Why are you reassigning NEW_DT twice in a row?
And what is '$1'?

Sorry for that. Please ignore NEW_DT=$1
Basically I want to have the parameter as today date from the NEW_DT field.

OK, but I still don't understand what's wrong.
How far have you gotten debugging the issue and what are the symptoms?