nmap端口扫描
#!/bin/sh
read -p "Enter the network you want to scan:" ip_network
read -p "Enter the port you want to scan(manay:(1 2 3)|1):" port
for IP in `seq 254`;do
ip_net=`echo $ip_network | awk -F . '{print $1"."$2"."$3}'`
ipadd="$ip_net.$IP"
for i in $port;do
A=$(nmap -p $i $ipadd | grep "open")
if [ -n "$A" ];then 判断字符是否为空,变量要加上双引号
echo $ipadd $i >> /tmp/sql.log
fi
done
done