Capturing System Command Output with Perl on Windows/Apache

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I have a problem trying to figure out why my Perl script, which works
fine from a DOS prompt, won't work when running via http.

The script simply does a quick "whois" and is meant to output the
results. When run from DOS it works fine, but when running under http
it ends up never finishing, never outputting anything, and with an
error in the error log (if I don't use eval), per the below:

(70007)The timeout specified has expired: ap_content_length_filter:
apr_bucket_read() failed

So, I've tried this a couple of different ways, but the most recent
incarnation, with pretty printing stripped out, is below:

# -------

my $cmd    =join('','c:/apache/cgi/whois.exe',' ',$host);

undef my @results;

eval {
    local $SIG = sub { die "TIMEDOUT" };
    @results    =`$cmd`;     # i.e. using back-ticks

print @results;

# -------

I am really curious, not to mention a little frustrated, since I know
that from the command line it works fine, and is very fast (usually a
response within a second or so).

Perl = version 5.8.
Apache = 2.x.
O.S. = XP Pro.

Any assistance appreciated.


Re: Capturing System Command Output with Perl on Windows/Apache

Yes, I am printing http headers, etc. :-)

Re: Capturing System Command Output with Perl on Windows/Apache

Whoa ... The weirdest thing .. I have now got it working, and will
explain below, but I still don't know exactly why it makes a
difference ... If someone can explain that would be even better!

In short, it was not a Perl issue.

What I did was to right-click on my whois.exe program and go into
Properties, and then select the Compatibility tab. In the
Compatibility tab one has the option to run a Windows program in
various compatibility modes (i.e. run it in Windows 95 compatibility
mode, or Windows 98, etc, etc). Anyway, I selected Windows 95
Compatibility mode, and lo-and-behold I am now getting output in http,
which I was not before.

I suspect if other people have third-party programs, for which they
are having a similar problem, then this might be something worth

Site Timeline