Sponsored Content
Top Forums Shell Programming and Scripting Can i see wich Computers are up in my network with a script Post 302944618 by gull04 on Wednesday 20th of May 2015 03:36:40 PM
Old 05-20-2015
I think that this is what you want;

Code:
#!/bin/bash

for ((n = ${1} ; n < ${2} ; n+=1))
do
    ip=192.168.1.$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

To run the script do as follows;

Code:
[root@ekbit13 bin]# ./testping.sh 10 20
192.168.1.10 is down
192.168.1.11 is down
192.168.1.12 is up
192.168.1.13 is down
192.168.1.14 is down
192.168.1.15 is down
192.168.1.16 is down
192.168.1.17 is down
192.168.1.18 is up
192.168.1.19 is down
[root@ekbit13 bin]#

The range is dependent on the two numbers that you provide after the script name, so for example;

Code:
[root@ekbit13 bin]# ./testping.sh 1 20
192.168.1.1 is up
192.168.1.2 is down
192.168.1.3 is down
192.168.1.4 is down
192.168.1.5 is down
192.168.1.6 is down
192.168.1.7 is down
192.168.1.8 is down
192.168.1.9 is down
192.168.1.10 is down
192.168.1.11 is down
192.168.1.12 is up
192.168.1.13 is down
192.168.1.14 is down
192.168.1.15 is down
192.168.1.16 is down
192.168.1.17 is down
192.168.1.18 is up
192.168.1.19 is down
[root@ekbit13 bin]#

Will ping from 1 to 20, as to adding switches as in your request for a "-t" which increments the IP address by 200 - you'll need to specify if it's output that you want changed or the actual address that is pinged.

Of course you could just use something like Xymon or Nagios and have it monitored all the time and automatically.

Regards

Gull

Last edited by gull04; 05-20-2015 at 04:44 PM.. Reason: Incomplete info
 

9 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Wich one is beter Linux or Windows

I have no idea wich one. Ive always been a huge windows fan and well latly i've heard of Unix and Linux. Also, my friend wants to get Linux on his notebook and windows on his pc, the notebook being the master.(I think my friend is rather stupid wanting the notebook to be the master, but i've been... (3 Replies)
Discussion started by: Radionstorm
3 Replies

2. UNIX for Advanced & Expert Users

Is Unix a Network operating system for Macintosh computers

I am in the process of reading up on and learning about linux,and as i read, i am seeing that it was built off of the unix system platform,and i also believe that it is used in the mac computer field,i would like to know if this is true, and if i should learn about the macintosh computer... (2 Replies)
Discussion started by: Bill1263
2 Replies

3. Shell Programming and Scripting

Script to get IP addresses of LAN computers

I need a shell script for OS X, one that can find IP addresses of machines connected to my LAN, get the names of the computer associated with those addresses, then display them like so in a list: "Bob's L33T Boxx: #.#.#.#" Something like the network scanner in Apple Remote Desktop is what I'm... (1 Reply)
Discussion started by: sladuuch
1 Replies

4. UNIX for Dummies Questions & Answers

So if I was to use a unix based o/s as my first wich should it be?

I have never used any unix based operating systems and I am interested in trying. Wich would you prefer for me to use? Also I am looking to learn unix code not to use for anything else. (3 Replies)
Discussion started by: Slaviko
3 Replies

5. Programming

read a file wich fscanf() in a function

I use fopen, fscanf, fclose to read a file. It can work well. since many files should be read, a function is created with the same code. But in the function, fscanf can not work well. for example, the first line of the the file is: > filename but the fscanf will give: 207/23/eee/34 it appears... (2 Replies)
Discussion started by: cdbug
2 Replies

6. HP-UX

CSA wich exam?

Hello, I'm looking books and information for CSA certificate but in HP website, appears the right exam is HP0-091 but I found a book in amazon about HP0-A01 (includes 11.31?)exam, I think this is the last exam but it's extrange the HP website are obsolete. Anyone known wich is the right exam... (4 Replies)
Discussion started by: RuBiCK
4 Replies

7. Shell Programming and Scripting

Shell script to Shutdown Computers on Cluster

Hello all. I have built a cluster of 9 Macs for computational chemistry and I need a shell script that I can use from one computer to all the rest to shutdown. I have modified all of the Macs so that there is pass-wordless ssh. As well, I have modified each "visudo" file on each machine by... (1 Reply)
Discussion started by: marcozd
1 Replies

8. Red Hat

How do I network a Suse installed machine with other computers, specifically Red hat Linux?

How do I network a Suse installed machine with other computers, specifically Red hat Linux? This is for a school project, and I can't find any pages that tell how to network a Suse to other computers except how to use a printer. (1 Reply)
Discussion started by: Anna Hussie
1 Replies

9. Fedora

Script for shutting down 48 computers

Hi All, I am pretty new to unix type languages. At work we have a server room with about 50 windows computers in one system and 50 in a unix system. We sometimes have power outages and I don't like the power slam. I wrote a windows batch file using sysinternals help to shutdown the windows... (4 Replies)
Discussion started by: Jeff Rollins
4 Replies
TUNCTL(8)						      System Manager's Manual							 TUNCTL(8)

NAME
tunctl -- create and manage persistent TUN/TAP interfaces SYNOPSIS
tunctl [-f tun-clone-device] [-u owner] [-t device-name] tunctl [-f tun-clone-device] -d device-name DESCRIPTION
This manual page documents briefly the tunctl command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. Instead, it has documentation in HTML format; see below. tunctl allows the host sysadmin to preconfigure a TUN/TAP device for use by a particular user. That user may open and use the device, but may not change any aspects of the host side of the interface. USAGE
To create an interface for use by a particular user, invoke tunctl without the -d option: # tunctl -u someuser Set 'tap0' persistent and owned by 'someuser' Then, configure the interface as normal: # ifconfig tap0 192.168.0.254 up # route add -host 192.168.0.253 dev tap0 # bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp' # arp -Ds 192.168.0.253 eth0 pub To delete the interface, use the -d option: # tunctl -d tap0 Set 'tap0' nonpersistent SEE ALSO
The UserModeLinux-HOWTO (link to URL http://user-mode-linux.sourceforge.net/UserModeLinux-HOWTO.html) AUTHOR
tunctl was written by Jeff Dike jdike@karaya.com This manual page was written by Matt Zimmerman mdz@debian.org for the Debian GNU/Linux system, based on examples from Jeff Dike. TUNCTL(8)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy