我使用nmap掃描網絡中的可用IP,我想僅使用PHP只掃描IP地址並僅保存陣列中的IP地址。在日誌文件中只搜索IP並保存在陣列中
這裏是文本文件輸出。
Starting Nmap 6.40 (http://nmap.org) at 2013-10-15 22:07 SE Asia Standard Time
Nmap scan report for 110.77.144.25
Host is up (0.042s latency).
Nmap scan report for 110.77.144.27
Host is up (0.051s latency).
Nmap scan report for 110.77.144.88
Host is up (0.033s latency).
Nmap scan report for 110.77.144.90
Host is up (0.037s latency).
Nmap scan report for 110.77.144.91
Host is up (0.038s latency).
Nmap scan report for 110.77.144.92
Host is up (0.034s latency).
Nmap scan report for 110.77.144.93
Host is up (0.035s latency).
Nmap scan report for 110.77.144.137
Host is up (0.063s latency).
Nmap scan report for 110.77.144.139
Host is up (0.037s latency).
Nmap scan report for 110.77.144.145
Host is up (0.064s latency).
Nmap scan report for 110.77.144.161
Host is up (0.074s latency).
Nmap done: 256 IP addresses (42 hosts up) scanned in 14.44 seconds
我想輸出保存在數組這樣
$available = array("110.77.233.1", "110.77.233.2",
"110.77.233.3", "110.77.233.4",
"110.77.254.16");
我如何與PHP做什麼?
'nmap -oX'會給你一個很好的XML格式,這可能更容易(也更可靠)檢查。 (xpath:'// host [status [@ state =「up」]]/address/@ addr') – Wrikken