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
Perl config file Help Harikrishna Shell Programming and Scripting 2 05-21-2008 09:07 PM
Perl config file Help Harikrishna Shell Programming and Scripting 6 05-20-2008 01:51 AM
Perl config file Help Harikrishna Shell Programming and Scripting 5 05-19-2008 01:40 AM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-09-2007 11:25 PM
bash and its config file XP_2600 SUN Solaris 1 03-22-2006 04:43 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-05-2006
Registered User
 

Join Date: Jul 2006
Posts: 6
using config file

Hello

I got script where is defined path name, connect string to database and
name of the log file.

I would like to create a new config file which will be consists of these path name, connect string and name of the log file.

But I don't know how to use this config file into the main script?
Or how to create a nice config file for other use?


For example of config file:
# TEMPORARY INCREMENT FILE
pivot='/tmp/.fileCount'

# CONNECTING STRING
USERNAME aaaaa
PASSWORD bbbbb
DBNAME xxxxx
---------------------------------------------

Thanks a lot
Reply With Quote
Forum Sponsor
  #2  
Old 09-06-2006
Registered User
 

Join Date: Aug 2006
Posts: 122
I think this is what you are looking for....let me know if it is not.
(Assuming you are using sh or ksh)
in your config file do stuff like....

# This is the configuration file for XXX
# Please place double quotes around all entries that have spaces in there
# values after the equals sign, ie FileList="file1 file2 file3"
#
#This parameter is the name of the logfile
logfile=/tmp/log.out
#
#
# TEMPORARY INCREMENT FILE
pivot='"tmp/.fileCount"
#
# CONNECTING STRING
# Place user name here
USERNAME=aaaaa
#
#Place passwd here
PASSWORD=bbbbb
#
#Place Dbname here
DBNAME=xxxxx
#
#this is the end of the config file

Now in your MAIN script all you do is....

#!/bin/sh
# This is my main script
# First need to source the config file
# if we can not read the cfg then exit!
if [ -r /path/to/config.cfg ]
then
# getting config file
. /path/to/config.cfg
else
echo "Can not read config.cfg
exit 99
fi

echo "$logfile"
echo "$pivot"
echo "$USERNAME"
echo "$PASSWORD"
echo "$DBNAME"


You can use "." or the "eval" inside your main script to source the information from your config file depends how and what you are sourcing

Hope this is what you are after
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 11:52 PM.


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