According to the book, "MacPerl -
Power and Ease" (Chapter 17, p. 239):
Too bad, because I really needed ICMP ping to monitor my flakey
DSL connection (due to the "well known" sync-no-surf problem
with my Alcatel SpeedTouch Home modem -- hangs, probably when the line
get noisy, and has to be rebooted or power-cycled. Let me know
if you have any experience with this problem. Also see the
security alert on this modem at http://security.sdsc.edu)
So here's a cheap trick to get this capability from MacPerl.
Sergey Tolkachev in '97-'98 wrote a set of useful HyperCard XCMDs
contained in his stack, HyperHTTP.PPC (which you can find on the usual
HyperCard archives), and released them as "freeware for
non-commercial use". Since I only needed the ping XCMD, I
extracted it with ResEdit to a much smaller separate file, Ping.XCMD,
attached here.
Here's a trivial MacPerl script which uses this XCMD to ping my
DSL provider's two DNS servers every 5 minutes. (If I can't get
to them, it's certain that my DSL modem is hung.)
========================================
#!perl -w
package Ping;
MacPerl::LoadExternals("Ping.XCMD");
package main;
while (1) {
print
Ping::Ping("206.13.28.12"), " at ", (scalar
localtime), "\n";
print
Ping::Ping("206.13.31.12"), " at ", (scalar
localtime), "\n";
sleep 300;
}
package Ping;
MacPerl::LoadExternals("Ping.XCMD");
package main;
while (1) {
========================================
which produces output like:
206.13.28.12 Alive at Sun May 6 16:00:16 2001
206.13.31.12 Alive at Sun May 6 16:00:16 2001
206.13.28.12 Alive at Sun May 6 16:05:15 2001
206.13.31.12 Alive at Sun May 6 16:05:15 2001
206.13.28.12 Not respond at Sun May 6 16:10:19 2001
206.13.31.12 Not respond at Sun May 6 16:10:24 2001
206.13.31.12 Alive at Sun May 6 16:00:16 2001
206.13.28.12 Alive at Sun May 6 16:05:15 2001
206.13.31.12 Alive at Sun May 6 16:05:15 2001
206.13.28.12 Not respond at Sun May 6 16:10:19 2001
206.13.31.12 Not respond at Sun May 6 16:10:24 2001
... sigh, time to reboot the modem...
Note the capitalization of the file and XCMD above.
HyperCard is very casual about capitalization, but MacPerl
isn't.
The XCMD is limited; you can't change the ping timeout or the
text of the response, but it does what I needed. If you give it
a hostname (e.g., "www.apple.com") rather than a
dotted-decimal host address, it'll do a DNS lookup before the ping.
But I wanted to use the test in its most primitive form.
The security alert cited above gives some interesting hints on
how to get signal-to-noise (and other operational) data out of the
Alcatel modem. So now that I can "ping" to test if my
link is up, I'm getting ready to use Net::Telnet to query the modem on
a regular basis to extract S/N data (to see if I can diagnose what's
causing the hangs) and to automatically reboot the modem.
Mike Wirth
Palo Alto, CA
PS: Perhaps someone who understands the MacPerl distribution
better than I do can put this XCMD and these instructions in an
appropriate repository.