![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |