I have a question is there any possibility for maken a script that you can see if computers are on in your network when you run the script for ex. ./ping.sh 54 62 62 , a script when you give as argument the last digit of the ip adres of the computers my network is 192.168.129.0 This is what i already have but i want to give extra parameters to the script for example parameter 1: xx-yy: this parameter ensures that all computers be test in the range of xx-yy eg. 61-67, test all the 7 computers with the last digit parameter 2: -t , ensures that each number count with 200 eg. -t 17 test the ip adress 217 , -t 17-19 test all the adresses 217 to 219 for ip in192.168.1.{1..10};do# for loop and the {} operator ping -c 1-t 1192.168.1.1>/dev/null 2>/dev/null # ping and discard output if[ $?-eq 0];then# check the exit code echo "${ip} is up"# display the output else echo "${ip} is down" fi done
I use: Code: #!/usr/bin/env bash network=${1} is_alive() { ping -b -c 1 ${i} > /dev/null [[ $? -eq 0 ]] && echo "${i} is up" } for i in ${network}.{0..254} do is_alive ${i} & disown done ./ping.sh 10.0.0