Reading a value from the configuration file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a value from the configuration file
# 1  
Old 02-16-2009
Reading a value from the configuration file

Hi,
I have prepared a config file in which I am declaring the value for a country such as: COUNTRY=USA
Now I am trying to read the country from the config file and print a message based on the same. I have written the following code in a script and when executing the script I getting an error.

Code:

cd /root/IMAGE_SAMPLE/
source ./country.conf
if [ "$COUNTRY" != "" ]
then
echo "Installtion in progress for $COUNTRY"
fi

Result:

[root@SNRBBY34844 IMAGE_SAMPLE]# chmod 777 ./Country_Sample.sh
[root@SNRBBY34844 IMAGE_SAMPLE]# ./Country_Sample.sh
: No such file or directory: cd: /root/IMAGE_SAMPLE/
: No such file or directory: ./country.conf
./Country_Sample.sh: line 8: syntax error: unexpected end of file

Can you please help?? Thanks in advance....Smilie
# 2  
Old 02-16-2009
Quote:
Originally Posted by yoursdavinder
[root@SNRBBY34844 IMAGE_SAMPLE]# ./Country_Sample.sh
: No such file or directory: cd: /root/IMAGE_SAMPLE/
: No such file or directory: ./country.conf
./Country_Sample.sh: line 8: syntax error: unexpected end of file
There's your problem. Make sure that the directory you want to change to really exists. Also, reading and (at least) trying to understand error messages can go a long way when debugging a script.
# 3  
Old 02-16-2009
Thanks for your response....The directory does exist, its the correct path and also the file country.conf

Can u pls help??
# 4  
Old 02-16-2009
Did you use a dos/windows editor?

Regards
# 5  
Old 02-16-2009
Are you absolutely sure? Change into that dir on the console, issue a 'pwd', and compare that output with the value set in your script.
# 6  
Old 02-16-2009
Yes I am sure that I am issuing the command in the same directory...
# 7  
Old 02-16-2009
Quote:
Originally Posted by Franklin52
Did you use a dos/windows editor?

Regards
I am using a windows editor
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies

2. Programming

Reading a router configuration file

Hello C specialists, I'm trying to write a program to read out a binary configuration file produced by a router. But the output of Name and Value is cryptic. What's going wrong? The structure of the binary file is very simple: struct nvram_tuple { char *name; char *value; ... (5 Replies)
Discussion started by: digidax
5 Replies

3. Shell Programming and Scripting

reading configuration files in bash. Best way?

Context: I have a random pin number generator script that reads a tab-delimited file containing a location and a count: eg., mansfield 30 tokyo 15 smithville 34It produces random PIN# in the amount specified by the number in the second column. Currently, I read the file... (7 Replies)
Discussion started by: Bubnoff
7 Replies

4. Shell Programming and Scripting

Configuration File

Hi I need a cofiguration file for my perl script... Suppose my perl script for counting total number of user is #!/usr/bin/perl -w $total_users; #To get how many users currently logged in########### $total_users=`who | wc -l`; print... (2 Replies)
Discussion started by: Harikrishna
2 Replies

5. Solaris

configuration file

Hi all-interesting forum. I am new with Solaris and i would like your advice on this: I am using a solaris 8 (ultra sparc IIi) workstation at my work,and i am trying to built another one exactly the same-so if the first one fails to have another one as backup. The problem is that the guy who... (1 Reply)
Discussion started by: ioa_pol
1 Replies

6. Shell Programming and Scripting

configuration file

i am trying to use a configuration file to FTP some files.. i am not sure how to call or use a configuration file in script. can anybody help (5 Replies)
Discussion started by: iamcool
5 Replies

7. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies

8. 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

9. Shell Programming and Scripting

How to create iso file according configuration file?

Hi folks, I have the following configuration file,which contains list of directories: /tmp> cat utils.conf Backup CPSync Change_Listener_Port Create_Database Deinstall Install_CPPlugin Project_migrator I have the following command in my ksh program: mkisofs -l -L -R -V ${PACK_NAME}... (1 Reply)
Discussion started by: nir_s
1 Replies

10. UNIX for Dummies Questions & Answers

Configuration file?

Anyone know which configuration file stores the users who are not permitted to use the at command? (2 Replies)
Discussion started by: Relykk
2 Replies
Login or Register to Ask a Question