$temp = shell_exec('ifconfig -a | grep flags');
$temp = preg_replace("/: flags=.*\n/"," ",$temp);
echo 'The interface are:
" . $temp;
$temp = shell_exec('ifconfig -Aa | grep inet');
$temp = preg_replace('/^\s+(inet6.*)|(.*127.0.0.1.*)\n/m',"",$temp);
$temp2 = preg_replace('/^\s+inet (.*)netmask (.*) broadcast.*/m',"ip:$1 netmask:$2",$temp);
echo "
The IP are:
" . $temp2;
获取IP时,注意要加上-A参数,否则alias的Ip会不显示。
阅读(1510) | 评论(0) | 转发(0) |