thanks Rodger,

I had Initially tried using 'eval' however it seemed to me that no exceptions were thrown by the function call within the eval {system...} but within the called program itself, I may be wrong. In either case that method brought me no success unfortunately.


From: Rodger Castle <[EMAIL PROTECTED]>
To: modperl@perl.apache.org
Subject: Re: Read from Apache error.log
Date: Sun, 27 Mar 2005 06:59:44 -0500

> Hello, im very new to the perl, modperl and apache combination.
>

So am I, but I think I have a usable solution for you.

> I am invoking another program from within my perl module using a
> 'System(...)' call. Although the call is successfull, there are times when
> the invoked program may terminate with a 'parse error:' for example, and
> theses are logged in the error.log. Is there a way the catch or read this as
> it happens and display to the browser?


Here's what I do ... add the line

use Carp;

to your Module list (checkout the perldocs on it for full details)

Wrap your call in an 'eval {};' block.  Example ...

eval
{
System.call (...); # This is the call that you're expecting an error from
}; ## Don't forget the semi-colon
if ( $@ )
{
$r->print ( "Uh oh. Error found: $@" );
carp ( $@ );
}


The eval acts as an exception handler. There is some discussion on the mod_perl site for using eval and Carp for exception handling.

Hope the helps.

Rodger




Reply via email to