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,

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="

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,

"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:

##-
##- 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. :slight_smile:

Cheers,
Cameron