![]() |
Media Access Control |
On Windows Machine
ob_start();
system('ipconfig /all');
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean();
$findme = "Physical";
$pos = strpos($mycom, $findme);
$macp=substr($mycom,($pos+36),17);
echo "The mac id of this system is :".$macp;
On Linux Machine
It is very easy in Linux, Just run the ip addr command and grep for ‘link/ether’. Then use awk to pring the 2nd variable.
<?php
echo "The mac id of this system is :";
system("/sbin/ip addr|/bin/grep link/ether | /bin/awk '{print $2}'");
?>
0 Comments