Reading the Properties File From Shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading the Properties File From Shell script
# 1  
Old 08-13-2010
Reading the Properties File From Shell script

Hi,

I am new to the shell script please I need help for following question.
I have properties file name called "com.test.properties" I have No of key values in this properties.

Code:
com.person.name = xyz
com.person.age = 55
com.person.address = hello

I want read this properties but i have other properties also but i want read only
above properties.

I tried in the following way. but it's not working. because key is having .

Code:
#!/bin/sh
# Sample shell script to read and act on properties

# source the properties:
. com.test.properties

# Then reference then:
echo $com.person.name;

Please any one know any other way help thanks in advance

Thanks
Venu J

Moderator's Comments:
Mod Comment Use code tags please, ty.
# 2  
Old 08-13-2010
When you want to use them as shell variables in the way you do, you may not use a dot in the variable name, as you already noticed. Also there may be no blanks between the name and the equal sign nor between the equal sign and the value.

Of course you can do something like:
Code:
$> VAR="com.person.name = xyz"
$> echo $VAR
com.person.name = xyz

You can also read them into an array as elements, etc.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading properties from file and setting variable values

I want to read properties from a file and print evaluated values of each key. I am using AIX6.1. myfile.props protocol=http siteA.host=siteAhostname pageA=pageNameA siteAURL1=${protocol}:/${siteA.host}/pagea/blabla?v1=32 siteAURL2=${protocol}:/${siteA.host}/${pageA}/blabla?v1=32... (5 Replies)
Discussion started by: kchinnam
5 Replies

2. Shell Programming and Scripting

Shell script reading file slow

I have shell program as below #!/bin/sh echo ======= LogManageri start ========== #This directory is getting the raw data from remote server Raw_data=/opt/ftplogs # This directory is ready for process the data Processing_dir=/opt/processing_dir # This directory is prcoessed files and... (4 Replies)
Discussion started by: Chenchireddy
4 Replies

3. AIX

Reading .properties file on AIX and Windows

I have a FirstDoc application that integrates with SharePoint 2010. As per the FirstDoc install guide, I need to generate the sharepoint_authentication properties file and place it on the server and the 2 Windows boxes that contain other components of the app. The properties file I... (1 Reply)
Discussion started by: shoefiend
1 Replies

4. Shell Programming and Scripting

Reading arguments for a shell script from file

I have a shell script that takes 2 arguments. I will have to execute this script multiple times with different values for the arguments. for example, ./shscript env1 value1 ./shscript env1 value2 ./shscript env2 value3 ./shscript env3 value4 ./shscript env1 value5 ./shscript env3... (24 Replies)
Discussion started by: goddevil
24 Replies

5. Shell Programming and Scripting

Error while reading from a file in shell script

Hi All, I'm writing a script to read a file line by line and then perform awk function on it. I am getting an error . My file has one name in it "James". I'm expecting my o/p to be youareJamesbond James ./users.sh: line 7: =: command not found #script to read file line by line #adding... (5 Replies)
Discussion started by: Irishboy24
5 Replies

6. Shell Programming and Scripting

Reading a property file through shell script???

Hi! i need a script that can read a property file. i.e., A script to read a "property" from property file. Read the property value and based on value of property, decide whether to start the some dataload activity or not. Its urngent. Can anyone help me out???:( (7 Replies)
Discussion started by: sukhdip
7 Replies

7. Shell Programming and Scripting

reading in properties file

Hi Am new to this scripting stuff so bear with me. I got a script made now that reads in a properties file. The properties file is in the following format: 256= Bos, Sea, FRa 128= HEL I want to be able to read in each line of the file and split out the letter fields by the numbered field. This... (2 Replies)
Discussion started by: vsekvsek
2 Replies

8. Shell Programming and Scripting

Problem with reading from a properties file

Hi, i have a properties file a.prop where entry is like PROCESS_IDX=0 Now in my shell schript i am doing like this. #!/bin/sh . a.prop .............. -....................... while read line do # tokenize the string by ",". var=(`echo $line | tr ',' ' '`) echo $PROCESS_IDX -->... (6 Replies)
Discussion started by: sailaja_80
6 Replies

9. Shell Programming and Scripting

file reading through shell script

For reading a file through shell script I am using yhe code : while read line do echo $line done<data.txt It reads all the line of that file data.txt. Content of data.txt looks like: code=y sql=y total no of sql files=4 a.sql b.sql c.sql d.sql cpp=n c=y total no of c files=1 (4 Replies)
Discussion started by: Dip
4 Replies

10. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question