我基本上想要以下内容:
#full .co.uk/.com domain names are kept in /var/www/vhosts
for each in /var/www/vhosts
do
echo "Attempting to ping $each"
ping -c 1 $each
if [ $? comes back with an IP ]; then
echo "The web server for $each is responding. $each points to $IPADDRESS"
domainlist=`echo "$each points to $IPADDRESS" >> domaintoiplist.txt`
echo ""
else
echo "Host $each is not reachable!"
fi
done
我无法工作的一点是 ping 无论如何都会返回 0 的退出状态。我是否需要以下解决方案:Ping 功能有不良结果