Re: Read from Apache error.log

[prev] [thread] [next] [Date index for 2005/03/27]

From: Rodger Castle
Subject: Re: Read from Apache error.log
Date: 11:59 on 27 Mar 2005
> Hello, im very new to the perl, modperl and apache combination.
>=20

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=20
> 'System(...)' call. Although the call is successfull, there are times whe=
n=20
> the invoked program may terminate with a '=07parse error:' for example, a=
nd=20
> theses are logged in the error.log. Is there a way the catch or read this=
 as=20
> 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

Read from Apache error.log
Femi Oshagbemi 11:47 on 27 Mar 2005

Re: Read from Apache error.log
Rodger Castle 11:59 on 27 Mar 2005

Re: Read from Apache error.log
Femi Oshagbemi 12:30 on 27 Mar 2005

Re: Read from Apache error.log
Rodger Castle 12:39 on 27 Mar 2005

Re: Read from Apache error.log
Clinton Gormley 14:08 on 27 Mar 2005

Re: Read from Apache error.log
Stas Bekman 15:08 on 27 Mar 2005

Generated at 09:30 on 27 Apr 2005 by mariachi v0.52