Jie Gao wrote:
[...]
That's great, Jie. Could you rewrite it not to use any external applications,
but pure perl? The problem with external apps is that args and location vary
from platform to platfrom and even from one release to another. Also using
perl we won't need to write a separate implementation for each platform. e.g.
$^O tells you the OS name. Not sure what's the best way to implement a quick
simple ping, CPAN has a few implementations but if we can avoid creating extra
dependencies at this level that would be great. Perhaps creating a pair of
sockets (local and INET) could make for a quick test.


This problem is Solaris (8, 9) specific, and "uname" and "ping" hardly
changes at all, and in fact, they _should_ not change its existing
behaviour at all, otherwise it will break a lot of things for sure.

we both know that "should" and the reality don't always match. But the real thing I'm trying to solve is not to write a separate branch for each supported OS, but have one piece of code that checks them all. Granted we can have a hash of hints to resolve the problem suited for each platform. So please bear with me.


So this should work (for a long time to come):

if ($^O eq 'solaris') {
    my $release = `/bin/uname -r`;

can't you get this info from Config.pm?


% perl -le 'use Config; print $Config{osvers}'
2.6.0-1mdkenterprise

    chomp $release;
    if (defined $release && $release >= 5.8) {
        my $ret = 0xffff & system('/usr/sbin/ping localhost 3 > /dev/null 2>&1');

and /usr/sbin is not in the normal user's PATH? If it is I'd prefer to call Apache::Util::which('ping'). or may be someone can contibute a lightweighted tcp ping implementation based on the core modules (w/o creating extra deps on CPAN modules).


        unless ($ret == 0) {
            print "localhost is down. Please check your loopback interface. Look into 
/etc/inet/ipnodes, and if you are not using IPv6, comment out the line \"::1  localhost\" and 
try this test again.\n";
        }

So I'd like to see this generic test:


1) which ping
2) run ping if found
3) if failed print a generic error message (e.g. can't resolve 'localhost') or a custom one if exists (like you added above).


Ideally I'd love to see 1+2 replaced with a pure perl tcp ping implementation.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to