nmap 扫描端口是否开放的shell脚本
vim checkip_nmap.sh
#!/bin/bash
. /etc/init.d/functions
FCMD="nmap -sP"
IP="192.168.31.0/24"
TCMD="nmap -sS"
UPIP=$FCMD $IP|grep "Nmap scan report for"|awk '{print $5}'
for ip in ${UPIP}
do
action "$ip is on line" /bin/true
UPPORT=$TCMD $ip|grep "open"|awk '{print $1}'
for port in ${UPPORT}
do
action "$ip $port is open" /bin/true
done
done
``