Skip Menu |

This queue is for tickets about the Net-Ping-External CPAN distribution.

Report information
The Basics
Id: 48908
Status: stalled
Priority: 0/
Queue: Net-Ping-External

People
Owner: Nobody in particular
Requestors: jwindsor [...] intelesyscorp.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Report a bug in Net-Ping-External
Date: Fri, 21 Aug 2009 08:17:05 -0400
To: bug-Net-Ping-External [...] rt.cpan.org
From: Jonathan Windsor <jwindsor [...] intelesyscorp.com>
The following example code works fine from the command line, but always returns a false when executed from a browser (IE) on the Web Server. ######################################## use Net::Ping::External qw(ping); my $alive = ping(host => "127.0.0.1"); print "\n\nalive = $alive<br>\n\n"; if ($alive) { print "\n\n<br>127.0.0.1 is online\n\n"; }else{ print "\n\n<br>127.0.0.1 is offline\n\n"; } ###################################### Command Line Results: ----------------------------------- alive = 1 127.0.0.1 is online Browser (IE) Results: ------------------------------- alive = 0 127.0.0.1 is offline 1. Binary build 822 ActiveState Perl 2. Perl v5.8.8 built for MSWin32-x86-multi-thread 3. Operating Sytems Windows 2003 Server, IIS 6.0.
On Fri Aug 21 08:17:33 2009, jwindsor@intelesyscorp.com wrote: Show quoted text
> The following example code works fine from the command line, but always > returns a false when executed from a browser (IE) on the Web Server. > ######################################## > use Net::Ping::External qw(ping); > my $alive = ping(host => "127.0.0.1"); > print "\n\nalive = $alive<br>\n\n"; > > if ($alive) { > print "\n\n<br>127.0.0.1 is online\n\n"; > }else{ > print "\n\n<br>127.0.0.1 is offline\n\n"; > } > ###################################### > Command Line Results: > ----------------------------------- > alive = 1 > 127.0.0.1 is online > > Browser (IE) Results: > ------------------------------- > alive = 0 > 127.0.0.1 is offline > > > 1. Binary build 822 ActiveState Perl > 2. Perl v5.8.8 built for MSWin32-x86-multi-thread > 3. Operating Sytems Windows 2003 Server, IIS 6.0.
It sounds to me like the web server doesn't have ping in its path which can be simulated as follows. BEGIN { delete $ENV{PATH}; } use Net::Ping::External qw(ping); my $alive = ping(host => "127.0.0.1"); print "\n\nalive = $alive<br>\n\n"; if ($alive) { print "\n\n<br>127.0.0.1 is online\n\n"; }else{ print "\n\n<br>127.0.0.1 is offline\n\n"; } Open a command prompt and run 'where ping'. Then you'll need to add that path to the environment. BEGIN { $ENV{PATH} = 'c:\Windows\System32'; } use Net::Ping::External qw(ping); my $alive = ping(host => "127.0.0.1"); print "\n\nalive = $alive<br>\n\n"; if ($alive) { print "\n\n<br>127.0.0.1 is online\n\n"; }else{ print "\n\n<br>127.0.0.1 is offline\n\n"; }