From owner-freebsd-hackers Thu Jan 2 12:22:58 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4A04337B407 for ; Thu, 2 Jan 2003 12:22:53 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08FA043ED4 for ; Thu, 2 Jan 2003 12:22:52 -0800 (PST) (envelope-from phk@freebsd.org) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id h02KMkF4004352; Thu, 2 Jan 2003 21:22:46 +0100 (CET) (envelope-from phk@freebsd.org) To: kientzle@acm.org Cc: Terry Lambert , freebsd-hackers@freebsd.org Subject: Re: Reading rc.conf from C programs? From: phk@freebsd.org In-Reply-To: Your message of "Thu, 02 Jan 2003 12:18:55 PST." <3E149EAF.9040100@acm.org> Date: Thu, 02 Jan 2003 21:22:46 +0100 Message-ID: <4351.1041538966@critter.freebsd.dk> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <3E149EAF.9040100@acm.org>, Tim Kientzle writes: >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 You can get a decent simulation this way: #!/bin/sh echo "*** NOISE" set echo "*** DATA+NOISE" . /etc/rc.conf set Then pipe this into your program and separate the data from the noise. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message