LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2008, 01:47 AM   #1
rehan999
Member
 
Registered: Aug 2007
Posts: 134

Rep: Reputation: 15
Unhappy scripting


Good Morning

I have 20 Linux machnies with static IP's and all this machnies are installed with redhat enterprise linux 4.3 .

I want to write a script to check how many machnies are up and how many machnies are down.

Please help me out its urgent...

Thanks and Regards
Rehan
 
Old 03-31-2008, 01:53 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,831

Rep: Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559
Well a quick 'n dirty way is:

Code:
# Assume list of ip addrs in a file, 1 ip per line
for ip in `cat ips.dat`
do
    ping -c1 $ip >/dev/null/ 2>&1
    if [[ $? -eq 0 ]]
    then
        echo "$ip is up"
    else
        echo "$ip is down"
    fi
done
 
Old 04-04-2008, 03:11 AM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
try to use nmap. it's a lot quicker.
Code:
nmap -n -sP -iL ips.dat
nmap -n -sP 10.0.0.1 192.168.0.1 ...
 
Old 04-08-2008, 06:00 AM   #4
rehan999
Member
 
Registered: Aug 2007
Posts: 134

Original Poster
Rep: Reputation: 15
Thanks you very much for the replies.

# Assume list of ip addrs in a file, 1 ip per line
for ip in `cat ips.dat`
do
ping -c1 $ip >/dev/null/ 2>&1
if [[ $? -eq 0 ]]
then
echo "$ip is up"
else
echo "$ip is down"
fi
done


The code really helped me.i have just made modifications according to my requirment

Thanks u very much
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
scripting help akhil.mud Programming 4 12-14-2007 07:28 AM
scripting kb100 Programming 16 08-17-2006 07:41 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
scripting anjiie Linux - Newbie 1 02-16-2004 09:17 AM
Scripting Askari Programming 1 12-09-2003 10:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:00 AM.

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