colinireland
-
Posts
3 -
Joined
-
Last visited
Posts posted by colinireland
-
-
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
-
Hello,
I am looking for a push in the right direction. I would like to be able to view a website that is duplicated on many servers by specifying the IP address. Similar to how one would use the hosts file.
I can do this using netcat
nc 1.2.3.4 80
Host: example.com
GET /contact-us.html
<CR><CR>
Can someone tell me how I would go about porting this to PHP? I would just like to set up a small page on my webserver where I can enter the domain and IP address and have the page displayed back to me.
Thanks Colin
$_SERVER['REMOTE_ADDR'] Help
in PHP Coding Help
Posted
Gave that a shot with...
and got
Still no idea why I can't pass it to exec correctly. I'm just trying to get the basic mechanism of getting the mac address in place. Will validate any input at a later stage though.