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

Discussion in 'Perl' started by yzhshi, Apr 5, 2004.

  1. yzhshi

    yzhshi Guest

    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 ;
    ---------------------------------------------------------------------------
     
    yzhshi, Apr 5, 2004
    #1
    1. Advertising

  2. yzhshi wrote:
    > 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
     
    Jürgen Exner, Apr 5, 2004
    #2
    1. Advertising

  3. yzhshi

    yzhshi Guest

    > 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:
    -------------------------------------------------

    while the browser result is:
    -------------------------------------------------
    Result! the out is: the err is:
    -------------------------------------------------
     
    yzhshi, Apr 5, 2004
    #3
  4. yzhshi wrote:
    >> 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.


    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
     
    Jürgen Exner, Apr 5, 2004
    #4
  5. yzhshi

    yzhshi Guest

    > 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 ....
     
    yzhshi, Apr 6, 2004
    #5
  6. (yzhshi) wrote in message news:<>...
    > > 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 ....


    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"
    }
     
    Alex939393929, Apr 6, 2004
    #6
  7. (yzhshi) wrote in message news:<>...
    > > 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 ....


    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"
    }
     
    Alex939393929, Apr 6, 2004
    #7
  8. yzhshi

    yzhshi Guest

    (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
     
    yzhshi, Apr 16, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page