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.
/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
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
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'?