Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I tell if a specific host is up on the network from a shell

0 views
Skip to first unread message

Norm Dresner

unread,
Feb 23, 1999, 3:00:00 AM2/23/99
to
I'd like to implement a shell that does something on each host on the
network that's up and running. I have (elsewhere) a list of possible
hosts. What's the simplest and fastest command to use in a shell to
determine in a for-loop for each one in turn whether or not it's up?

Thanks

Norm

Barry Margolin

unread,
Feb 23, 1999, 3:00:00 AM2/23/99
to
In article <01be5f47$673c62c0$8aea689b@w784749>,

Check if ping succeeds. Some versions of ping set their exit status based
on their success, so you can use it in an if statement.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

pe...@icke-reklam.netman.se.nu

unread,
Feb 23, 1999, 3:00:00 AM2/23/99
to
In comp.unix.admin Barry Margolin <bar...@bbnplanet.com> wrote:
> In article <01be5f47$673c62c0$8aea689b@w784749>,
> Norm Dresner <nd...@worldnet.att.net> wrote:
>>I'd like to implement a shell that does something on each host on the
>>network that's up and running. I have (elsewhere) a list of possible
>>hosts. What's the simplest and fastest command to use in a shell to
>>determine in a for-loop for each one in turn whether or not it's up?

Or get a copy of "fping", as i remember it it pings a list of
hosts and has possibilties to act if one host does not respond.

fping is available in FreeBSD ports tree.

> Check if ping succeeds. Some versions of ping set their exit status based
> on their success, so you can use it in an if statement.

> --
> Barry Margolin, bar...@bbnplanet.com
> GTE Internetworking, Powered by BBN, Burlington, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

--
--
Peter Håkanson Phone +46 0708 39 23 04
Network Management AB Fax +46 031 779 7844
Email : use peter (at) gbg (dot) netman (dot) se No copy to sanford wallace!

Cal Dunigan

unread,
Feb 23, 1999, 3:00:00 AM2/23/99
to
Just piggybacking here, I haven't seen the original post yet.

Another utility that I have used fot this purpose is rup. It isn't
available on all systems, but it returns a list of hosts running on
the local net. It can take a while to run, if your net is highly
volatile it may not be suitable. The scripts I wrote to use it kept
a log of successes and failures and tried again later, but I had a
pretty stable network of Unix boxes.

On Tue, 23 Feb 1999, Barry Margolin wrote:
> In article <01be5f47$673c62c0$8aea689b@w784749>,
> Norm Dresner <nd...@worldnet.att.net> wrote:
> >I'd like to implement a shell that does something on each host on the
> >network that's up and running. I have (elsewhere) a list of possible
> >hosts. What's the simplest and fastest command to use in a shell to
> >determine in a for-loop for each one in turn whether or not it's up?
>

> Check if ping succeeds. Some versions of ping set their exit status based
> on their success, so you can use it in an if statement.
>
> --
> Barry Margolin, bar...@bbnplanet.com
> GTE Internetworking, Powered by BBN, Burlington, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
>
>

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Cal Dunigan c...@goodnet.com There is something fundamentally
Consulting wrong with a world in which Ken
Modeling Thompson lives in obscurity and
Training Bill Gates is a famous billionaire.
//////////////////////////////////////////////////////////////////////


Michael Nelson

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
On Tue, 23 Feb 1999 16:20:34 GMT, Norm Dresner wrote:
>I'd like to implement a shell that does something on each host on the
>network that's up and running. I have (elsewhere) a list of possible
>hosts. What's the simplest and fastest command to use in a shell to
>determine in a for-loop for each one in turn whether or not it's up?

"rup"

Michael

--
"Life is not a dress rehearsal" -- unknown

Michael Nelson San Francisco, CA nel...@imat.com

Arthur Hagen

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to

In article <slrn7d6qtr...@seahunt.imat.com>, nel...@seahunt.imat.com writes:
> On Tue, 23 Feb 1999 16:20:34 GMT, Norm Dresner wrote:
> >I'd like to implement a shell that does something on each host on the
> >network that's up and running. I have (elsewhere) a list of possible
> >hosts. What's the simplest and fastest command to use in a shell to
> >determine in a for-loop for each one in turn whether or not it's up?
>
> "rup"

rup depends on the hosts being available over RPC, and the rpc.statd
or rstatd daemon must be running on all hosts.

I'd say the fastest way to check which hosts are up on one network,
provided they are all physically located behind the same switch/router,
is to ping the broadcast or network address once, and check "arp -a".
At least if the hosts will answer broadcast pings :-)

Regards,
--
*Art

Jan Tellkamp

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
Barry Margolin <bar...@bbnplanet.com> writes:
> Check if ping succeeds. Some versions of ping set their exit status based
> on their success, so you can use it in an if statement.
>

Why don't ping the broadcast adress and then use arp?
This way you get a list of all hosts up and running.

Jan

Emmanuel Dreyfus

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
<pe...@icke-reklam.netman.se.nu> wrote:

> Or get a copy of "fping", as i remember it it pings a list of
> hosts and has possibilties to act if one host does not respond.
>
> fping is available in FreeBSD ports tree.

I did a NetBSD port, if anyone is interested (It's juste changing 3
lines in the sources)

--
Emmanuel Dreyfus.
Avec Windows 3.1 ils etaient au bord du gouffre...
Avec Windows 95 ils ont fait un grand bon en avant.
p99d...@criens.u-psud.fr

Dan Mercer

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
In article <slrn7d6qtr...@seahunt.imat.com>,

nel...@seahunt.imat.com (Michael Nelson) writes:
> On Tue, 23 Feb 1999 16:20:34 GMT, Norm Dresner wrote:
>>I'd like to implement a shell that does something on each host on the
>>network that's up and running. I have (elsewhere) a list of possible
>>hosts. What's the simplest and fastest command to use in a shell to
>>determine in a for-loop for each one in turn whether or not it's up?
>
> "rup"
>
> Michael
>
Using rup is no faster than actually trying the command with rsh -
meaning if the host is down, rup will have to time out. I know,
been there, did that. I now use fping, an order of magnitude faster
than just using individual pings.
--
Dan Mercer
dame...@uswest.net

Opinions expressed herein are my own and may not represent those of my employer.


J. S. Jensen

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
Jan Tellkamp wrote:

> Why don't ping the broadcast adress and then use arp?
> This way you get a list of all hosts up and running.

A lot of TCP/IP implementations won't respond to a broadcast ping. Windows
comes to mind here... :-(


--
J. S. Jensen
mailto:jsje...@Paramin.COM
http://www.Paramin.COM

Brian Smith

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to
J. S. Jensen <jsje...@Paramin.COM> wrote:
: A lot of TCP/IP implementations won't respond to a broadcast ping. Windows

: comes to mind here... :-(

This is actually a good thing though... the fewer implementations that are
out there that respond to broadcast pings, the fewer places that DOS
attackers can use to launch smurf attacks.

--
--------------------------------------------------------------
Brian Smith Software Developer/Programmer at Large
aval...@earthling.net http://home.dreamhaven.org/~morph/
--------------------------------------------------------------
It is a little known fact that Y1K caused the Dark Ages...

jsn...@my-dejanews.com

unread,
Feb 25, 1999, 3:00:00 AM2/25/99
to
In article <wk4sob3...@mail.gasops.co.uk>,
Shaun Lipscombe <shaun.l...@gasops.co.uk> wrote:
>
> Windows machines don't respond to broadcast pings :(
> Oh well, better install linux on them :)
>
> --
> Linux: The best things in life are free
>
>

Wrong group..
This is Silicon Graphics... Using Irix... Duhhh

John Snape
Senior Systems Specialist
Systems and Simulation
British Aerospace MA&A

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

DHobbs

unread,
Feb 26, 1999, 3:00:00 AM2/26/99
to
> In article <wk4sob3...@mail.gasops.co.uk>,
> Shaun Lipscombe <shaun.l...@gasops.co.uk> wrote:
> >
> > Windows machines don't respond to broadcast pings :(
> > Oh well, better install linux on them :)
> >
> > --
> > Linux: The best things in life are free
> >

This works in Solaris to make sure every machine is up:
-------------------------------------------------------------
#!/bin/sh
#check.hosts
# See if any of the hosts are down and report if they are
HOSTS=`cat /export/admin/scripts/HOSTS`
echo "Ping all machines and report hostname only if it is not pingable
" >> /export/admin/logs/checkh
ost.log
for x in $HOSTS ;do
ping $x 5 > /dev/null
if [ $? = 0 ]; then
echo "$x" > /dev/null
else
echo "$x is not on-line" >> /export/admin/logs/checkhost.log
fi

done
# mail the stuff to sys admin
#
/usr/ucb/mail -s "CheckHost" unixrepair <
/export/admin/logs/checkhost.log
# Clean Up After ourselves
rm /export/admin/scripts/checkhost.log
-------------------------------------------------------------------

Then have a file named HOSTS and put the name or IP address of the
machines you want to check. I've got this running as a crontab script
once an hour and I catch outages rather well like that.

Dan H

0 new messages