Date: Thu, 02 Jan 2003 17:31:30 -0800 From: Greg Shenaut <greg@bogslab.ucdavis.edu> To: hackers@FreeBSD.ORG Subject: Re: Reading rc.conf from C programs? Message-ID: <200301030131.h031VUx83048@thistle.bogs.org> In-Reply-To: Your message of "Thu, 02 Jan 2003 12:18:55 PST." <3E149EAF.9040100@acm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <3E149EAF.9040100@acm.org>, Tim Kientzle cleopede: >Terry Lambert wrote: > >> Tim Kientzle wrote: >>>I'm trying to figure out how to read and use >>>/etc/rc.conf configuration variables from within >>>a C program. >> >> #!/bin/sh >> # Throw all of rc.conf into the environemnet so a C program >> # named "fred" can read any of them with "getenv". >> . /etc/rc.conf >> fred > > >This doesn't work. /etc/rc.conf does not export >its variables to the environment. It only sets them in the >local shell. Try the above where 'fred' is > #!/bin/sh > printenv >and you'll see what I mean. Try using the "set -a" command before reading rc.conf and it will work: #!/bin/sh set -a . /etc/rc.conf exec yourprog Greg Shenaut To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301030131.h031VUx83048>