Hello,
I am trying to detemine the MAC address of a machine on a local network from the IP address.
The following code does exactly that.
<?php
$IP="192.168.1.18";
exec("ping -c 1 -s 1 $IP");
$mac=exec("/usr/sbin/arp -an | /bin/grep $IP | /usr/bin/awk '{print $4}'");
echo "$IP - $mac";
?>
However I need to take the IP address from an HTML form. When using the $_SERVER['REMOTE_ADDR'] variable seems to screw things up for me. Maybe its not the correct type of variable? For example the following will not work.
<?php
$IP=$_SERVER['REMOTE_ADDR'];
exec("ping -c 1 -s 1 $IP");
$mac=exec("/usr/sbin/arp -an | /bin/grep $IP | /usr/bin/awk '{print $4}'");
echo "$IP - $mac";
?>
Can anyone explain why this is? Our suggest an alternative method of doing this?
Regards,
Colin