Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Can i see wich Computers are up in my network with a script

$
0
0
Code:

#!/bin/bash

for ((n=0 ; n < 254 ; n+=1))
do
    ip=192.168.0.$n
    if ping -c 1 -w 1 $ip > /dev/null 2> /dev/null >> /etc/logping.txt; then 
        echo "${ip} is up" # output up
        # sintax >> /etc/logping.txt log with .txt format
    else
        echo "${ip} is down" # output down
    fi
done

This is code that I already have when i run the script ./testping.sh 220
than i gave this out put
Code:

192.168.0.0 is down
192.168.0.1 is up
192.168.....
...
.
.
.
.
192.168.0.220

Now I want to limit the output to two lines but it doesn't work

I want to also implement 2 arguments to this script
the argument xx-yy en -t
xx-yy a range of IP address when I give the parameter ./testping.sh 67-80 it scans the range between this IP addresses

-t counts the IP address with 200 for example, when I run the script with the parameter -t , ./testping.sh -t 17 , then I want as output 192.168.0.217

Viewing all articles
Browse latest Browse all 16232

Trending Articles