#!/bin/bash
dir=/root/UPdate/$1
[ -e /tmp/fd1 ] || mkfifo /tmp/fd1
exec 3<>/tmp/fd1
rm -rf /tmp/fd1
for ((i=1;i<=10;i++))
do
echo >&3
sleep 1
done
for ip in cat $dir/ping_fail
;do
read -u3
{
for i in 80 8080 443 3389 22;do
nc -z -w5 $ip $i 2>&1 >/dev/null
if [ $? -eq “0” ];then
echo nc $ip $i successful
echo $ip $i success>> $dir/nc_success
else
echo $ip $i failed>> $dir/nc_fail
fi
done
echo >&3
}&
done
exec 3<&-
exec 3>&-