b49b rc.conf + rc Script ==> get all related vars - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old April 29th, 2012, 14:26
Leander Leander is offline
Junior Member
 
Join Date: Apr 2010
Location: Stuttgart
Posts: 58
Thanks: 4
Thanked 0 Times in 0 Posts
Default rc.conf + rc Script ==> get all related vars

Hi there,

I want to write a rc script. My rc.conf should hold information for it in following format:

Code:
md_enable="YES"
md_file_md0="/path/to/file-0"
md_file_md1="/path/to/file-1"
md_file_md2="/path/to/file-2"
Now I want something like this in my rc start script to find out about all "md_file_md" related variables:

Code:
for FILE in $md_file_md*; do
    echo $FILE
done
Obviuosly I could write something by the help of sed / awk to filter for md0, md1, md2, md[n] in rc.conf file ... but I was hoping the rc framework has somthing like this already? Or is there any better ideas of how to solve this easier?

Thanks
Reply With Quote
  #2  
Old April 29th, 2012, 15:00
graudeejs's Avatar
graudeejs graudeejs is offline
Style(9) Addict
 
Join Date: Nov 2008
Location: Riga, Latvia
Posts: 4,523
Thanks: 422
Thanked 607 Times in 475 Posts
Default

Why not to set
Code:
md_files="/path/to/file-0 /path/to/file-1 /path/to/file-2"
?
Reply With Quote
  #3  
Old April 29th, 2012, 17:05
Leander Leander is offline
Junior Member
 
Join Date: Apr 2010
Location: Stuttgart
Posts: 58
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by graudeejs View Post
Why not to set
Code:
md_files="/path/to/file-0 /path/to/file-1 /path/to/file-2"
?
Thanks for your input. I thought about such a solution already but the issue is that this method would not relate md dev number with file definition ... So it is not really usable for my needs.
Reply With Quote
  #4  
Old April 29th, 2012, 20:52
Leander Leander is offline
Junior Member
 
Join Date: Apr 2010
Location: Stuttgart
Posts: 58
Thanks: 4
Thanked 0 Times in 0 Posts
Default

FYI: http://forums.freebsd.org/showthread...540#post175540
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restart the script in newsyslog.conf oksidant General 1 January 20th, 2012 08:08
sh -> vars in [ -a ] aren't evalueated correctly Seeker Userland Programming & Scripting 11 November 13th, 2011 18:44
Odd behaviour related to rc.conf gman88 Web & Network Services 3 July 23rd, 2010 00:54
Python script which checks for syntax error in rc.conf Kami Userland Programming & Scripting 23 May 5th, 2010 17:07
[Solved] Exporting env vars to other xterms sim General 3 November 14th, 2009 04:25


All times are GMT +1. The time now is 22:23.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0