LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-22-2004, 01:33 AM   #1
Neorio
Member
 
Registered: Jun 2003
Distribution: Debian
Posts: 110

Rep: Reputation: 15
bash scripting - how to make config file?


I have several scripts which all have common variables.
How to I modify the scripts to read a single config file containing these common variables?

At the moment all my scripts have a section up the top which defines the same variables.
 
Old 10-22-2004, 02:52 AM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Let's say you have eg. file config.rc containing:
Code:
foo=bar
baz=bafl
Now having line
Code:
source /path/to/config.rc
in other script should include the variables there.
 
Old 10-22-2004, 04:52 AM   #3
Neorio
Member
 
Registered: Jun 2003
Distribution: Debian
Posts: 110

Original Poster
Rep: Reputation: 15
Thanks.

I also found another way to do it, simply by loading the config file with variables and having them loaded in using the period command within the script.

. /configpath/configfile
 
Old 10-22-2004, 06:39 AM   #4
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
That is fundamentally the same solution; "." is an alias for "source".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH Shell Scripting -- foreach file in folder??? AC97Conquerer Programming 11 07-06-2011 12:25 AM
Bash Scripting Empty file john8675309 Linux - Software 2 08-08-2007 04:05 PM
How To Make Installer In Linux Bash Scripting pak_abdul Programming 1 05-24-2005 08:37 AM
bash scripting read from file cadj Programming 2 02-29-2004 10:42 PM
bash scripting - largest # file extension brian0918 Programming 3 06-16-2003 12:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration