我正在输出一个域列表,如下所示:
lastdomain=`ls -lah /var/www/vhosts | wc -l`
#the variables below will be used later
IP1=`ifconfig | grep "inet addr" | sed '1 ! d' | awk '{print $2;}' | cut -c 6-19`
IP2=`ifconfig | grep "inet addr" | sed '2 ! d' | awk '{print $2;}' | cut -c 6-19`
LIST=`ls -lah /var/www/vhosts | sed "4,$lastdomain ! d" | awk '{print $9;}' | grep -v 'chroot\|default\|.skel'`
我想ping每个。这几乎有效:
for each in $LIST
do
echo "Attempting to ping $each..."
ping -c 1 $LIST > /dev/null 2>&1 #&& break
if [ "$?" -ne "0" ]; then
echo "Host $each is not reachable! "
else
break
fi
done
但是它们都返回为:
Host exampledomain.com is not reachable!
我究竟做错了什么?
编辑:现在它正在工作,我需要摆脱以下内容以获取 IP 地址:
PING domain.com (IP.IP.IP.IP) 56(84) bytes of data.
64 bytes from domain.co.uk (IP.IP.IP.IP): icmp_seq=1 ttl=64 time=0.024 ms
--- domain.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.024/0.024/0.024/0.000 ms