shell 测试多IP和和多端口的组合的连通性
cat ip_port.sh
###########################################
#!/bin/bash
ips=(
192.168.1.101
192.168.1.102
192.168.1.103
)
ports=(
11
22
33
)
for ip in ${ips[@]}
do
for port in ${ports[@]}
do
echo > /dev/tcp/${ip}/${port} > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "\033[32m${ip}:${port} is open.\033[0m"
fi
done
done
###########################################
#!/bin/bash
read -p "请输入一个整数: " number
expr ${number} “+” 1 > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "你的输入不合法,程序退出!"
exit
fi
if [[ ${number:0:1} == “0” ]] || [[ ${number:0:2} == “-0” ]]; then
echo "你的输入不合法,程序退出!"
exit
else
echo ${number}
for i in `seq 1 1 9`
do
echo "`echo ${number}${i}` = `expr ${number} \* ${i}`"
done
fi