need config file parsing code.

From: Date: Mon, 16 Jun 2003 08:14:50 +0000
Subject: need config file parsing code.
Groups: php.general 
Request: Send a blank email to php-general+get-151644@lists.php.net to get a copy of this message
I am writing an open source web page that I can't believe doesn't exist already. basically i want to see all the DHCP clients on my network AND their nice windows names -- that is the tricky part -- I can't find a tool that does that part. GRRR... Anyways, here is what I have so far if you want to see it: http://daevid.com/examples/dhcp/index.php To match up the names however I need to parse the /var/lib/dhcp/dhcp.leases file and map the "client-hostname" tag to the proper MAC address. So my question is, does anyone have some code (PHP preferred obviously, but any language should work or be portable) that will take a file of the form below and split it into the chunks required. Or anything even close? For example, a 'chunk' would be between the { and } . I'm sure I can figure this out, but before I go re-inventing the wheel, thought someone might have done this already to some degree. lease 192.168.1.3 { starts 1 2003/06/16 07:38:55; ends 1 2003/06/16 07:48:55; binding state active; next binding state free; hardware ethernet 00:80:45:31:d8:29; } lease 192.168.1.6 { starts 1 2003/06/16 07:39:27; ends 1 2003/06/16 07:49:27; binding state active; next binding state free; hardware ethernet 48:54:e8:26:23:38; uid "\001HT\350&#8"; client-hostname "jme"; } when the script is finished I'll post it up for anyone to use on their own servers... by the way, does anyone know why "arp -n" (what i'm using) shows machines that are NOT even turned on? like my notebook shows up despite having been off for several hours? Is there a way to get a real time list of the machines on my network? I thought that's what arp did, but apparently not. :( d

« previous php.general (#151644) next »