0

i want to get mac address of device of live server but i am unable to get it on live server although it is coming on localhost.

$MAC=exec('getmac'); 
$MAC=strtok($MAC, ' '); 
echo "MAC address of client is: $MAC"; 
brombeer
  • 8,716
  • 5
  • 21
  • 27
  • What error do you get? What have you done to debug? Does your live server allow `exec()`? – brombeer Jun 23 '20 at 04:43
  • bro i am not getting any king of error nothing is displaying when i try it on live server. – farhan Habib Jun 23 '20 at 04:45
  • **Nothing** is displaying? So your complete script doesn't run? Do you display errors? [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1) What OS is your live server? – brombeer Jun 23 '20 at 04:48
  • Warning: exec() has been disabled for security reasons in /home/hassanst/knowledgeinns.online/mac.php on line 4 – farhan Habib Jun 23 '20 at 04:53
  • And **that's** why you don't get output, you can't use `exec()` on your live server – brombeer Jun 23 '20 at 04:54
  • then sir what is solution for that? – farhan Habib Jun 23 '20 at 04:55
  • take a look here https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php – Zia Yamin Jun 23 '20 at 05:40

1 Answers1

0

On a linux system the NIC card MAC address stored in file /sys/class/net/<interface>/address.

for example:

/sys/class/net/eth0/address

EDIT:

You won't get the client's MAC address from your server as you are serving on the internet. If you're serving as an LAN network application, you can use arp command to query ip-mac mapping.

lindowx
  • 34
  • 5