[ltp] OT: how to time a ping command?

Marius Gedminas linux-thinkpad@linux-thinkpad.org
Mon, 20 Sep 2004 11:15:43 +0300


--Pk6IbRAofICFmK5e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Sep 19, 2004 at 08:49:51PM -0400, Eben King wrote:
> On Mon, 20 Sep 2004, Andr=E9 Wyrwa wrote:
> > Funny, that's exactly what i'm looking for, but my ping.1 doesn't
> > include this and neither does my ping.
> > Can you post your --version output please? Mine is from GNU inetutils
> > 1.4.2 .

Ping in Debian woody does not have a timeout option (-w) either.  Ping
in sarge does.

> I did something much faster (which I can't recall verbatim).  It would do=
=20
> something like
>=20
> ping -c 1 somehost > /dev/null &
> ping_pid=3D$!
> { sleep 1 ; kill $ping_pid ; } &
> sleep_pid=3D$!
> wait $ping_pid
> kill -0 $sleep_pid && # internet connection is up
> kill $sleep_pid
>=20
> (At least that's how I THINK I did it.)  Net effect was that you would
> only wait for the timeout if the ping wasn't returned.  Normally there
> would just be a ping then life would go on.

Eek.

I suggest fping.  It has sane timeouts (and is present in Debian woody).

Description: sends ICMP ECHO_REQUEST packets to network hosts
 fping is a ping like program which uses the Internet Control Message Proto=
col
 (ICMP) echo request to determine if a target host is responding.  fping
 differs from ping in that you can specify any number of targets on the com=
mand
 line, or specify a file containing the lists of targets to ping.  Instead =
of
 sending to one target until it times out or replies, fping will send out a
 ping packet and move on to the next target in a round-robin fashion.

Marius Gedminas
--=20
To err is human... to really foul up requires the root password.

--Pk6IbRAofICFmK5e
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBTpGukVdEXeem148RAtb/AJ49FZYQAvqw6O325pSqyJ+pAn1f4ACfVzpZ
5Z6xTCpotr1SXqICCVUlecU=
=CJqH
-----END PGP SIGNATURE-----

--Pk6IbRAofICFmK5e--