why i get different result from command line and browser?(not 500 Err)

Y

yzhshi

hello, the follow code get different result from Command line and
browser
that is to say ,i get the correct result from the command line,but i
cant say the result from browser.

IPC::RUN is used in this code; i get it from
http://ppm.activestate.com/PPMPackages/zips/8xx-builds-only/Windows/IPC-Run-0.77.zip

my environment is:
Microsoft windows 2000 professional
Apache 2.0.49
Active Perl 5.8.3.809

because i am new to perl,i can not solve this.
Please help!thanks a lot.

---------------------------------------------------------------------------
#!C:\perl\bin\perl.exe -w

use strict;
use IPC::Run qw(start finish) ;
use CGI::Carp qw(fatalsToBrowser);

print "Content-type: text/html\n\n";

my @cmd = qw(C:\winnt\system32\ping.exe) ;
push(@cmd,'www.google.com');
push(@cmd,'-n');
push(@cmd,'1');

my $h ;
local(*OUT,*ERR);
#this line cannot be modified
$h = start (\@cmd,\"" ,'>pipe', \*OUT, '2>pipe', \*ERR)|| die("can't
write some_file: $!");

print "Result!\n";
print "the out is:\n";print <OUT>;
print "the result is err\n"; print <ERR>;
close(OUT);
close(ERR);
finish $h ;
---------------------------------------------------------------------------
 
J

Jürgen Exner

yzhshi said:
hello, the follow code get different result from Command line and
browser
that is to say ,i get the correct result from the command line,but i
cant say the result from browser.

Did you check the answer in the FAQ?
Please see "perldoc -q 500" (althought the question is actually somewhat
different from yours, the answer applies in your case, too).

jue
 
Y

yzhshi

Did you check the answer in the FAQ?
Please see "perldoc -q 500" (althought the question is actually somewhat
different from yours, the answer applies in your case, too).

jue

thanks a lot.

Because i am a newer to perl. i read many faq recent although my pool
English...

just now i ran "perldoc -q 500" and read
http://www.perl.org/troubleshooting_CGI.html
but it can't run still.

can you tell me the reasion. thanks again.


from command i can got
-------------------------------------------------
C:\cvsweb>C:\perl\bin\perl a1.cgi
Content-type: text/html

Result!
the out is:

Pinging www.google.akadns.net [216.239.53.99] with 32 bytes of data:

Reply from 216.239.53.99: bytes=32 time<10ms TTL=128

Ping statistics for 216.239.53.99:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
the err is:
 
J

Jürgen Exner

yzhshi said:
thanks a lot.

Because i am a newer to perl. i read many faq recent although my pool
English...

just now i ran "perldoc -q 500" and read
http://www.perl.org/troubleshooting_CGI.html
but it can't run still.

can you tell me the reasion. thanks again.

If your program runs fine from the command line then you don't have a Perl
problem (there may be some very, very special exceptions).
You may have a problem with CGI, or your web server configuration, or
permissions, or your understanding of how CGI works, or a million of other
issues, none of them related to Perl.

You _really_ should ask in a newsgroup that deals with CGI and web servers
and web authoring and so on, just as suggested in the FAQ. They may be able
to help you.
But because your problem is not related to Perl it is very unlikely that
anyone in a Perl NG can help you.

jue
 
Y

yzhshi

You _really_ should ask in a newsgroup that deals with CGI and web servers
and web authoring and so on, just as suggested in the FAQ. They may be able
to help you.

Oh,yes. When I Search for this problem,I found the group
comp.infosystems.www.authoring.cgi last night,I think I can find the
answer there.
as a newbie of perl,i think I can find the resove way in perl group...
thanks, i will go there an search for that.

but i think i will paste the reason of the question here. for other
newbie just like me ....
 
A

Alex939393929

Oh,yes. When I Search for this problem,I found the group
comp.infosystems.www.authoring.cgi last night,I think I can find the
answer there.
as a newbie of perl,i think I can find the resove way in perl group...
thanks, i will go there an search for that.

but i think i will paste the reason of the question here. for other
newbie just like me ....

You could use Net::ping, this will circumvent several problems.

use Net::ping;
use Time::HiRes qw( gettimeofday tv_interval );

$bytes = 1024;
$timeout = 30;
$pingtype = "icmp";

$ping = Net::ping->new($pingtype , $timeout , $bytes);
while (true) {
if ($ping->ping($ARGV[0],5)) {
$t0 = [gettimeofday];
$elapsed = 1000 * tv_interval( $t0, [gettimeofday]);
print "Pinging $ARGV[0] with $bytes bytes of data rtt=$elapsed mSecs\n"
} else {
print "Host Could Not be Reached\n"
}
 
A

Alex939393929

Oh,yes. When I Search for this problem,I found the group
comp.infosystems.www.authoring.cgi last night,I think I can find the
answer there.
as a newbie of perl,i think I can find the resove way in perl group...
thanks, i will go there an search for that.

but i think i will paste the reason of the question here. for other
newbie just like me ....

You could use Net::ping, this will circumvent several problems.

use Net::ping;
use Time::HiRes qw( gettimeofday tv_interval );

$bytes = 1024;
$timeout = 30;
$pingtype = "icmp";

$ping = Net::ping->new($pingtype , $timeout , $bytes);
while (true) {
if ($ping->ping($ARGV[0],5)) {
$t0 = [gettimeofday];
$elapsed = 1000 * tv_interval( $t0, [gettimeofday]);
print "Pinging $ARGV[0] with $bytes bytes of data rtt=$elapsed mSecs\n"
} else {
print "Host Could Not be Reached\n"
}
 
Y

yzhshi

(e-mail address removed) (Alex939393929) wrote in message
You could use Net::ping, this will circumvent several problems.

Oh,Thanks,this is only a example to describe this question.
In fact, I am not use ping, I want to use cvsweb in windows and meet this...

I found when I use IPC::RUN3 ,I can get the correct result from browser.

I think I shoud email the author and ask for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top