The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scheduling crontab using parameter from XML file michaelbz Shell Programming and Scripting 0 08-14-2007 06:49 AM
how do I make dynamic parameter names? Or get the value of a parameter evaluated twi Awanka Shell Programming and Scripting 2 04-19-2007 06:37 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 02:25 AM
parameter file for a shell script bryan Shell Programming and Scripting 2 02-25-2005 09:58 AM
max file parameter ( urgent ) fmmq Filesystems, Disks and Memory 2 07-25-2002 02:00 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-19-2007
Registered User
 

Join Date: Jul 2006
Posts: 183
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?
Reply With Quote
Forum Sponsor
  #2  
Old 12-19-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
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
Reply With Quote
  #3  
Old 12-19-2007
Registered User
 

Join Date: Jul 2006
Posts: 183
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
Reply With Quote
  #4  
Old 12-19-2007
Registered User
 

Join Date: Jul 2006
Posts: 183
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
Reply With Quote
  #5  
Old 12-19-2007
Registered User
 

Join Date: Jul 2006
Posts: 183
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
Reply With Quote
  #6  
Old 12-19-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
look at my original post:
Code:
#!/bin/ksh

for site in $(< /path/to/siteFile)
do
 update.ksh 20071912 1 "${site}"
done
Reply With Quote
  #7  
Old 12-19-2007
Registered User
 

Join Date: Jul 2006
Posts: 183
Thanks Vgresh!!!! Thats simply great.

can you let me know the significance of < here.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0