LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2007, 12:11 PM   #1
Rev.C
LQ Newbie
 
Registered: May 2005
Location: Caribbean
Distribution: Red Hat Enterprise 3
Posts: 1

Rep: Reputation: 0
Basic ping script


I just started out with bash scripting and decided to write a simple ping program that pings my network and record the host ip address. The program works but since it ping every host once, it takes to much time. Is there another (simple) way that the program ping every host but faster?

Thanks

Code:
#!/bin/bash

for ((n=0 ; n < 255 ; n+=1))
do
	ip=192.168.2.$n
	if ping -c 1 -w 1 $ip
	   then
		host=&ip
        echo $host>>livehost
        fi
done
 
Old 01-29-2007, 12:38 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
It depends for what you are pinging an host.

There is the fping program. It could be used in your scripting not inside a loop, but specifying the range of ips to ping, in just one command.
There is the nmap program too, which is used as a network discovery tool. It can check if a host is up, not just sending ICMP packets but sending half-protocol and guessing the status without complete the protocol.
And there is the nice arpalert tool, which uses the ARP protocol to create a list of hosts in your site, and send alerts when a new host is plugged in your network.

I hope one of theses can satisfy your requirements.
 
  


Reply

Tags
ping, script



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a basic script rsmccain Programming 5 07-03-2006 06:28 AM
Basic Shell Script Help Vasquez Linux - Newbie 3 02-28-2005 07:14 PM
Basic shell script, please help colly Linux - General 4 10-05-2004 11:24 AM
Basic networking IPTable Do I have to?? I canīt ping my machines jimdaworm Linux - Networking 18 11-29-2003 11:10 PM
Help with basic Administrator Script NightWolf_NZ Programming 1 09-11-2003 01:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration