Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Capturing System Command Output with Perl on Windows/Apache

Reply
Thread Tools

Capturing System Command Output with Perl on Windows/Apache

 
 
Jasper2000
Guest
Posts: n/a
 
      02-25-2010
Hi,

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{ALRM} = sub { die "TIMEDOUT" };
alarm(10);
@results =`$cmd`; # i.e. using back-ticks
alarm(0);
};

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.

Thanks!





 
Reply With Quote
 
 
 
 
Jasper2000
Guest
Posts: n/a
 
      02-25-2010
Yes, I am printing http headers, etc.


 
Reply With Quote
 
 
 
 
Jasper2000
Guest
Posts: n/a
 
      02-25-2010
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
trying.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing output of os.system to a string gerry.butler Python 2 11-24-2009 02:11 AM
Capturing actual Browser output in perl digz Perl Misc 3 05-23-2009 11:55 PM
Capturing shell command output and success? Kyle Schmitt Ruby 9 08-06-2008 06:35 PM
capturing output of command line in an array amjadcsu@gmail.com Python 4 11-01-2007 03:49 AM
Pull out only first field of ps command ( in Perl ) PERL RUN COMMAND tweetiebirds@gmail.com Perl Misc 2 03-26-2005 06:03 AM



Advertisments