The snippet you sent worked fine for me both at the command line and through CGI (Linux RH 8.0, Apache 2.x, Perl 5.8.0, Mozilla 1.2.x). Is there anything abnormal about your perl setup? What version of Perl and IPC::Open2 do you have? Are the permissions set correct on the script? Sounds like it may not be a problem with your script, but rather a problem with the environment. Anything out of the ordinary that you know of?

http://danconia.org

Miroslav Suchy wrote:
Wiggins D'Anconia wrote:

I am not sure if Open2 automagically autoflushes the IO so you may want to turn on autoflushing and try again to see if that helps. You should also turn on warnings with 'use warnings' and see if that gives any more information.

Don't know why other than not flushing the buffers this would work any different from the command line than CGI.

Seting autoflushing on/off do not help.

When I turn the warnings on, I get this warning in apache error log:
Use of uninitialized value in concatenation (.) or string at /www/imprese.cz/sexy/no_mod_perl/test.cgi line 24, <Reader> line 1.
And that is because I try print $line and $line was only assigned by scalar(<Reader) which is undef (why, why, why - I'm going crazy).
When run from command line, there is no warnings at all.

Here is code without ispell (if you wanna try):

#!/usr/bin/perl -w
use strict;
use IPC::Open2;
use warnings;
use CGI;

my $pid = open2(
*Reader,
*Writer,
'/bin/cat',
);

my $q=new CGI;
print $q->header, $q->start_html;

print Writer "lupou\n";
my $line=scalar(<Reader>);
print scalar((defined $line) ? $line : 'undef');

print $q->end_html;

when run from command line it produce:
some http and html headers
lupou
some html foot

and as cgi under apache:
undef
instead of the string 'lupou'

Miroslav Suchy






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to