reading the parameter from another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading the parameter from another file
# 8  
Old 12-19-2007
Code:
cat file | xargs -n 1 update.ksh 20071912 1

# 9  
Old 12-19-2007
from 'man ksh'
Code:
       < file standard  input  is  redirected  from  file, which is opened for
              reading.

# 10  
Old 12-19-2007
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
# 11  
Old 12-19-2007
Quote:
Originally Posted by dsravan
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':
Code:
       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.

# 12  
Old 12-19-2007
'$( 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:
Code:
#!/bin/ksh
$ echo 'fred' > foo
$ echo $(<foo)
fred

# 13  
Old 12-20-2007
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
# 14  
Old 12-20-2007
Quote:
Originally Posted by dsravan
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'?
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