[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] re: Ping.pm



"John W." <johnw@imagelinc.com> writes:
} >} To Mac-Perl,
} >}
} >} I've been trying to use the 'ping.pm' module to set
} >} up a ping script.  The line in this module:
} >}
} >} $echoport = (getservbyname('echo', 'tcp')) [2];
} >}
} >} doesn't return anything on the Mac, but works fine
} >} on my DEC.
} >
} >It may be that MacPerl just doesn't know the port number for echo.  I
} >discovered today that it doesn't know syslog as I was getting Syslog.pm
} >working, but just giving it the port number by hand should work.  Be
} 
} Hard coding '$echoport = 7;' doesn't work either.  I looked for
} 'tcp' services on ports 1-5000 and didn't find 'echo' services.

I just ran the following script:

#!/usr/local/bin/perl
use Net::Ping;
print "leprss\n" if pingecho('leprss.gsfc.nasa.gov', 10) ;
print "schinder\n" if pingecho('schinder.clark.net', 10) ;
print "explorer2\n" if pingecho('explorer2.clark.net',10);

after I fixed the Ping.pm in the :lib:Net folder of the MacPerl folder.  The
first change was

$echo_port = (getservbyname('echo', 'tcp'))[2] || 7;

The other was to comment out all of the alarm stuff, since it doesn't
work under MacPerl.  This means, of course, that the second argument is
superfluous.  (Oh, well, that's life.  You want Unix, run Unix.)

The result of the script:

leprss
schinder
explorer2

leprss.gsfc.nasa.gov is my Sun workstation at work, and I know (since I
am the omniescent omnipotent root) it's running tcp echo on port 7.
schinder.clark.net is my Mac (Powerbook 165, System 7.5.3, OT 1.1)
which always runs MacTCPWatcher and Daemon when I'm online.
explorer2.clark.net is one of the Sun workstations at my ISP.  So
apparently

1: Ping.pm works when you make the necessary changes.  You no longer
have any control over the timeout (at least not with alarm, although
you might be able to change it some other way).

2: Experimenting with the script shows the following about
MacTCPWatcher: it will answer a single tcp echo and then won't answer
again until it's restarted.  Weird.  And apparently OT and/or Daemon
do *not* answer tcp echo (probably only ICMP echo).  With Daemon and
MacTCPWatcher both shut down, the Mac (so presumably OT, since this
never worked under MacTCP) answers ICMP echo (via ping(8C) from leprss)

} 
} ---------------------------------------------------
} John Whelan
} johnw@imagelinc.com
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us