I'm writing a PHP script that autoconfigures a device over Telnet, and I need to grab some IP addresses from /etc/hosts
I need it to grab the IP address only, and assign it to a variable based on the hosts name. Example:
192.168.1.50 machine
192.168.1.51 printer
192.168.1.52 sigpad
The PHP script should be like this:
$machineip = "192.168.1.50";
$printerip = "192.168.1.51";
$sigpadip = "192.168.1.52";
Of course, my /etc/hosts
file is different, but you'll get the idea from my example. I'll then be able to include this PHP script to any of our existing programs, and use the variables instead of hardcoded IP addresses.