![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
Read configuration from a text file?
I'm working on an automated installer for Slackware Linux, much like Windows unattended setup, which simply reads configuration from unattend.inf. I'm trying to find a decent way to replicate the config file, and have no clue on how to use bash to read in from a file like so:
RootPartition=/dev/hda2 #!/bin/sh ROOT=/dev/hda2 SWAP=/dev/hda3 KERNEL=bareacpi.i etc. export ROOT export SWAP export KERNEL etc. |
|
|
|
|
|
#2 |
|
Professional Programmer
|
look up the Bash Advanced Guide. You can read in the text line by line, then parse the string splitting it by the '=' the left variable will become the name, the right variable will become the value. If the parser sees the 'export' keyword, it reads the line in differently, namely it splits the line by the ' ' and the left part gets discarded, while the right part gets added to an array of modules to export. Or something like that.
Good luck Dizz |
|
|
|
|
|
#3 |
|
Newbie
|
I normally just source the config file.
Something like: [ -f config.conf ] && . config.conf |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Ummm, this thread was just about a year old !?!? -- ?!?!?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Happy birthday, thread
.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Newbie
|
So it is. Found it on the first page so didn't think it would be any more then a few days old. I guess I need to get used to the pace of these forums.
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() ![]() |
Apparently, my original reply didn't go through... so here it is in summary.
-- I could see where that is a bit misleading. Fortunately, the other sections have a faster pace. Hopefully, we can spark some life back into this one. ![]()
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#8 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Quote:
Try the Lounge - it has about 90% of all the posts on the site.. ![]() And, Dawei has about 40% of all posts on the site. You do the math... Because of the dearth of new threads, every new programming question gets jumped on right away. This is good for the questioner. Assuming he/she follows the Forum rules. |
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
That's FOUR percent, not FORTY :p . An' I ain' th' top poster
.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|