LinuxQuestions.org
Review your favorite Linux distribution.
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 08-09-2004, 11:03 AM   #1
michael_util
Member
 
Registered: Feb 2004
Posts: 47

Rep: Reputation: 15
Bash programming .. multiple includes ??


Hello,

I am working on a bash script that will act as a wrapper for another process. So it will constantly be running, 24x7 ... so I want to make sure it is stable and not a memory hog.

When the script starts it looks for a config file and if found does a include:

. ${home}/${config}

Now if you send the process a kill -1 signal it cause the wrapper to run through the configuration again to make any changes. The problem I had was if I make changes to the config file the wrapper does not know about them because the process never shuts down and so the config file is in memory ...

So for the script to know about the changes I need to re-include the config file.

So the question is, is this the best way ? If so ... if I do a include on the same config file multiple times ... what happens to the variables and memory ?

I would assume the varaibles would just get update with the new info but would the memory consumption goes up ?


Michael.
 
Old 08-09-2004, 11:25 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Re: Bash programming .. multiple includes ??

Quote:
Originally posted by michael_util
So for the script to know about the changes I need to re-include the config file.
Yes, true. "sourcing" is a better word than "Including" in this case. (the reserved word "source" does the same as the dot (.)

Quote:
So the question is, is this the best way ? If so ... if I do a include on the same config file multiple times ... what happens to the variables and memory ?

I would assume the varaibles would just get update with the new info but would the memory consumption goes up ?
Memory won't go up, unless new variables are created in the new config file.

Also take care not to have any syntax-errors in your config file, as they would exit the script (you sound like you really don't want that to happen :-)
 
Old 08-09-2004, 11:47 AM   #3
michael_util
Member
 
Registered: Feb 2004
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks for the info ... you are correct that I am sourcing the "config" file and the yes ... a syntax error would not be a good thing ...

Thanks for the reply.

Michael.
 
  


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 Programming moodupani Programming 1 08-31-2005 06:50 PM
bash programming alaios Programming 2 07-23-2005 12:52 AM
bash programming drisay Programming 6 12-20-2004 09:09 AM
bash script includes? MIC_Rulz Linux - Software 2 09-07-2004 05:46 PM
bash programming cpukiller Linux - Newbie 1 11-04-2003 06:45 PM


All times are GMT -5. The time now is 10:20 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration