Config file use in Shell Programs...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Config file use in Shell Programs...
# 1  
Old 10-03-2007
Config file use in Shell Programs...

I wanted to know the format everyone uses for cfg files that are called by shell programs. I do mostly sh and ksh scripts and many times I'm modifying an existing script to do another task.

Recently I have been making my scripts more generic and using configuration files to hold uniq details. Thus making modification quick and easy.

Currently, I use a CSV "like" format for my scripts. I would like something that is more human readable and meaningful with larger number of entries. XML would over complicate things but I have been looking into YAML. Does anyone have any feed back or suggested best practices on configuration files used in shell programs?

Thanks,
# 2  
Old 10-03-2007
Quote:
Originally Posted by tomas
Does anyone have any feed back or suggested best practices on configuration files used in shell programs?
I actually like configuration files which are shell scripts and are merely "." or sourced into the running script. Typically you will find rc.conf etc managed this way.

Another common standard is "resource files" as used by X.

I have also seen UNIX programs using the "win.ini" format, eg "[stanza]" and "value="
# 3  
Old 10-03-2007
Good point. I'm a SA coming from the hardware world to the software side of things. Does POSIX or another standards group address things like this? I see your point about rc files and conf. Since I work in a mixed UNIX shop I should take a look around and see what examples I can find on the base distribution.

Thanks,
# 4  
Old 10-04-2007
"A thousand ways to sink a cat" I used to hear old timers say ...

I use heaps of configuration files (I prefer to call them "environment" files) for scripts that I create and maintain. They vary from System, Oracle, Tuxedo and script specific requirements, across numerous Oracle instances. Why; purely for ease of use and creating generic scripts that are extremely portable between instances.

An example:
Code:
##-
##- Environment Variables for:   [Oracle-SID]
##-

##- GMT OFFSET SETTING -##

  US_GMT_OFFSET='-5'

##----------------------##

##- Generic HouseKeeping Environment Variables -##
EMAIL_SUPPORT="support1@support.com,support2@support.com"
HOUSEKEEPING_EML_ADD='housekeeping@domain-name.com'
SMS_ALERT="sms@support.com"

##- A-Customer Specific Environment Variables -##
XXX_IP_DNS="IP-or-DNS-Entry"
XXX_USR1="A-UID-1"
XXX_USR2="A-UID-2"

##- Security Specific Environment Variables -##
SECFILE=/opt/Security/header.txt
DELIMIT=80

##- Variables used in Script: FTPOUT-CFS.sh        -##
##- All references must stay as script is shared.  -##
FR_EMAIL_SUPPORT="emea-fr-support@domain-name.com"
UK_EMAIL_SUPPORT="emea-uk-support@domain-name.com"
US_EMAIL_SUPPORT="amer-us-support@domain-name.com"
ZZ_EMAIL_SUPPORT="amer-zz-support@domain-name.com"

The example is a cut down sample, but they can be as large or as small as required.

TIP: I'm in the practise of ensuring that UID's and PWD's are kept in separate environment/configuration files if not using SSH/SFTP. I suspect others would do the same too. The above only contains UID's, the PWD's are contained in another environment/configuration file.

Hope that helps some. Smilie

Cheers,
Cameron

Last edited by Cameron; 10-04-2007 at 10:47 AM.. Reason: sad spelling :(
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

2. Shell Programming and Scripting

Update config file using shell script in Solaris 5.10

hi I need to update the value in config.txt value using shell script example: lets say a value in config.txt file is as SEQUENCE=1 after some iteration as the loop ends , the SEQUENCE should get update in the config.txt file with a new value of SEQUENCE=2. also , can anyone please help me... (7 Replies)
Discussion started by: ravidwivedi2288
7 Replies

3. UNIX for Advanced & Expert Users

What files or programs have the ability to change your default network scripts and config

What files or programs have the ability to change your default network scripts and config files? All 3 of these very important files got changed on their own. /etc/sysconfig/network-scripts/ifcfg-wlan0 /etc/sysconfig/networking/devices/ifcfg-wlan0... (4 Replies)
Discussion started by: cokedude
4 Replies

4. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

5. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

6. UNIX for Dummies Questions & Answers

Are programs like sys_open( ) ,sys_read( ) et al examples of system level programs ?

Are the programs written on schedulers ,thread library , process management, memory management, et al called systems programs ? How are they different from the programs that implement functions like open() , printf() , scanf() , read() .. they have a prefix sys_open, sys_close, sys_read etc , right... (1 Reply)
Discussion started by: vishwamitra
1 Replies

7. Shell Programming and Scripting

how to access variables in a config file inside a shell script

I'm writing a shell script. I want to put the variables in a separate config files and use those inside my script. e.g. the config file (temp.conf)will have the values like mapping=123 file_name=xyz.txt I want to access these variables in temp.conf(i.e. mapping and file_name) from inside the... (7 Replies)
Discussion started by: badrimohanty
7 Replies

8. Shell Programming and Scripting

Edit a config file using shell script

I need to edit a config file using shell script. i.e., Search with the 'key' string and edit the 'value'. For eg: below is what I have in the config file "configfile.cfg". Key1=OldValue1 Key2=OldValue2 I want to search for "Key1" and change "OldValue1" to "NewValue1" Thanks for your... (7 Replies)
Discussion started by: rajeshomallur
7 Replies

9. Shell Programming and Scripting

How to parse config variables from external file to shell script

How do i use a config.txt to recursively pass a set of variables to a shell script eg my config.txt looks like this : path=c://dataset/set1 v1= a.bin v2= b.bin path=c://dataset/set2 v1= xy.bin v2= abc.bin .................. and so on . and my testscript : (2 Replies)
Discussion started by: pradsh
2 Replies

10. Shell Programming and Scripting

shell programs

how to write pipe for finding out the login names and login time of the users whose login name begins with p. (1 Reply)
Discussion started by: rameshparsa
1 Replies
Login or Register to Ask a Question