ReadInterfaces
Aus Programmers Guide
(Unterschied zwischen Versionen)
Roy (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „= Die /etc/network/interfaces mit PHP auslesen = <source lang="php"> <?php function readInterfaces($was){ /* # This file describes the network interfaces availa…“) |
Roy (Diskussion | Beiträge) |
||
Zeile 43: | Zeile 43: | ||
</source> | </source> | ||
- | [[Category:PHP]][[Category:Snippet]] | + | [[WriteInterfaces]] |
+ | |||
+ | [[Category:PHP]] [[Category:Snippet]] |
Aktuelle Version vom 17:51, 6. Sep. 2010
Die /etc/network/interfaces mit PHP auslesen
<?php function readInterfaces($was){ /* # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth1 iface eth1 inet static address 192.168.1.245 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.253 dns-nameservers 192.168.1.253 dns-search elektrohauffe.intern */ $fileArray = file("/etc/network/interfaces"); foreach($fileArray as $key => $val){ if(preg_match("/".$was."/",$val)){ $splitter = preg_split("/ /",trim($val)); return $splitter[1]; } } return false; } //Beispiel readInterfaces('address'); readInterfaces('gateway'); ?>