• 周日. 5月 26th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

阿铭每日一题 day 11 20180121

admin

11月 28, 2021

方法一:

1 #!/bin/bash
2 
3 ip="192.168.0"
4 for i in `seq 1 254`
5 do
6   ping -c 2 $ip.$i |grep -q "ttl=" && echo "$ip.$i up..." >> /tmp/ping_ip.txt || echo "$ip.$i down..." >> /tmp/ping_ip.txt
7 done

方法二:

#! /bin/bash  
for siteip in $(seq 1 254)  
do  
    site="192.168.0.${siteip}"  

#-c的意思ping的次数
#-n在输出数据时不进行IP与主机名的反查,直接使用IP输出速度快
#-W 等待响应对方主机的秒数
    ping -c1 -W1  ${site} &> /dev/null  
    if [ "$?" == "0" ]; then  
        echo "$site is up" > /tmp/pingfile  
    else  
        echo "$site is down"  
    fi    
done 

day11参考答案:

#!/bin/bash

ips="192.168.1."
for i in `seq 1 254`
do

ping -c 2 $ips$i >/dev/null 2>/dev/null
if [ $? == 0 ]
then
    echo "echo $ips$i is online"
else
    echo "echo $ips$i is not online"
fi
done

《阿铭每日一题 day 11 20180121》有5个想法
  1. Wow, superb weblog structure! How lengthy
    have you ever been running a blog for? you made blogging glance easy.
    The whole look of your website is magnificent, let alone the content
    material! You can see similar here dobry sklep

  2. Oh my goodness! Impressive article dude! Thanks, However I am experiencing troubles with your RSS.

    I don’t understand why I am unable to join it.
    Is there anybody else having identical RSS issues?
    Anyone that knows the solution can you kindly respond?
    Thanks!! I saw similar here: Najlepszy sklep

  3. I do not even know the way I ended up right here, however I believed this post was once good.
    I don’t recognize who you are but definitely you are going to a famous blogger in case you aren’t already.
    Cheers! I saw similar here: Dobry sklep

  4. Hello! Do you know if they make any plugins to assist with
    SEO? I’m trying to get my site to rank for some targeted keywords
    but I’m not seeing very good gains. If you
    know of any please share. Kudos! You can read similar
    art here: Scrapebox AA List

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注