Sponsored Content
Top Forums Shell Programming and Scripting Can i see wich Computers are up in my network with a script Post 302944731 by Don Cragun on Thursday 21st of May 2015 01:33:38 PM
Old 05-21-2015
Quote:
Originally Posted by Roggy
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

NO, it does not! That code doesn't look at any command line arguments and always prints ping results for IP addresses 192.168.0.0 through 192.168.0.254.
Quote:
Originally Posted by Roggy

Now I want to limit the output to two lines but it doesn't work
Huh?
What two lines of output do you want to get from asking for the status of IPE address 192.168.0.220?
Quote:
Originally Posted by Roggy

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
Why do you keeping asking the same question? Doesn't the code I provided in post #5 in your previous thread do exactly this?
 

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
All times are GMT -4. The time now is 03:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy