Capturing System Command Output with Perl on Windows/Apache 
Author Message
 Capturing System Command Output with Perl on Windows/Apache


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);

eval {
    local $SIG{ALRM} = sub { die "TIMEDOUT" };



# -------

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.


Mon, 13 Aug 2012 16:15:39 GMT  
 Capturing System Command Output with Perl on Windows/Apache
Yes, I am printing http headers, etc. :-)

Mon, 13 Aug 2012 16:18:04 GMT  
 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

Mon, 13 Aug 2012 16:51:06 GMT  
 [ 3 post ] 

 Relevant Pages 

1. capturing output of executed system command

2. Capturing output of a system command

3. Capture output from system command?

4. capturing system command output

5. capturing command line error or output from `<command>`

6. Capturing command output in Perl

7. calling javac from perl and capturing system output

8. capturing output of FILEHANDLE "| command"

9. capturing output from a remote command (how?)

10. capturing output of piped commands

11. Most efficient method to call a system routine and capture it's output

12. Help with Piped command, capturing output


Powered by phpBB® Forum Software