You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tue Topholm <tt...@device.dk> on 2006/11/08 13:10:54 UTC

Mod_perl + cronolog

I have this script:

<Perl>
use DBI;
my ($sth, $dbh, $domain, $domainID, $created, $sql);
$dbh = DBI->connect("DBI:mysql:ccc:cccc","ccc","ccc");
$sth = $dbh->prepare("SELECT domainID, domain, created FROM domain ORDER BY
domainID ASC");
$sth->execute();
while (($domainID, $domain, $created) = $sth->fetchrow_array())
{
if($created == 0)
{
system("/bin/mkdir /home/$domain");
system("/bin/mkdir /home/$domain/www");
system("/bin/mkdir /home/$domain/ErrorLog");
system("/bin/chown apache:apache -R /home/$domain");
$sql = $dbh->prepare("UPDATE domain SET created = 1 WHERE domainID =
$domainID");
$sql->execute();
}
push @{ $VirtualHost{'*:80'} },
{
ServerName => "$domain",
ServerAdmin => " <mailto:postmaster@$domain%22> postmaster@$domain";,
ServerAlias => "www.$domain",
DocumentRoot => "/home/$domain/www",
ErrorLog => "/home/$domain/ErrorLog/$domain-error_log",
CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
combined",
};
}
$sth->finish();
$dbh->disconnect();
</Perl>

 

 

But it crashes when it tries to read the line:

CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
combined",

 

The failure is:
apachectl: Configuration syntax error, will not run "graceful":
Syntax error on line 2 of /vhosts/vhosts.conf:
$parms->add_config() has failed: error in condition clause at
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
thread-multi/Apache2/PerlSections.pm line 203.\n



If I remove this line, everything works just perfect.

 

How should I define cronolog??






 

Med venlig hilsen / Best Regards
Tue Topholm

Device.Webbureau
M: +45 26 74 07 41

P: +45 70 21 00 04
LinkedIN:  <http://www.linkedin.com/in/ttopholm>
http://www.linkedin.com/in/ttopholm

 

 


Re: SV: Mod_perl + cronolog

Posted by Lupe Christoph <lu...@lupe-christoph.de>.
On Wednesday, 2006-11-08 at 19:32:05 +0100, Tue Topholm wrote:

> I don't have problem with this, it works just fine...

Let me be explicit: that is shitty Perl code. I have no idea what is
causing your real problem, but you should not write code like that. What
you did is write a shell script in Perl.

I was trying to help you write better Perl code. But if you like your
code as it is, I can't help you. I would never accept code that did not
check if it succeeded.

> It is this line:

> CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
> combined",

> It gives me this failure:

> apachectl: Configuration syntax error, will not run "graceful":
> Syntax error on line 2 of /vhosts/vhosts.conf:
> $parms->add_config() has failed: error in condition clause at
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
> thread-multi/Apache2/PerlSections.pm line 203.\n

Perhaps you should check what line 203 in PerlSections.pm does.

Lupe Christoph
-- 
| You know we're sitting on four million pounds of fuel, one nuclear     |
| weapon and a thing that has 270,000 moving parts built by the lowest   |
| bidder. Makes you feel good, doesn't it?                               |
| Rockhound in "Armageddon", 1998, about the Space Shuttle               |

SV: SV: Mod_perl + cronolog

Posted by Tue Topholm <tt...@device.dk>.
Sweet, it works just perfect now....

Med venlig hilsen / Best Regards
Tue Topholm
Device.Webbureau
M: +45 26 74 07 41
P: +45 70 21 00 04
LinkedIN: http://www.linkedin.com/in/ttopholm

-----Oprindelig meddelelse-----
Fra: Perrin Harkins [mailto:perrin@elem.com] 
Sendt: 9. november 2006 06:32
Til: Tue Topholm
Cc: modperl@perl.apache.org
Emne: Re: SV: Mod_perl + cronolog

Tue Topholm wrote:
> Any idea what it could be?

I believe Charlie Garrison already told you the answer: you have to 
escape the % symbols in your double-quoted string.  They will be 
interpreted by perl as hashes.

> CustomLog => qq{"|/usr/sbin/cronolog
/home/log/$domain-access_log.%Y-%m-%d"

Try qq{"|/usr/sbin/cronolog /home/log/${domain}-access_log.\%Y-\%m-\%d"} 
instead.

- Perrin



Re: SV: Mod_perl + cronolog

Posted by Perrin Harkins <pe...@elem.com>.
Tue Topholm wrote:
> Any idea what it could be?

I believe Charlie Garrison already told you the answer: you have to 
escape the % symbols in your double-quoted string.  They will be 
interpreted by perl as hashes.

> CustomLog => qq{"|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d"

Try qq{"|/usr/sbin/cronolog /home/log/${domain}-access_log.\%Y-\%m-\%d"} 
instead.

- Perrin

SV: Mod_perl + cronolog

Posted by Tue Topholm <tt...@device.dk>.
Hi Dondi

I just tried it. 
When I restart apache it doesn't come up with any failures, but it doesn't
create any files in /home/log or /var/log/httpd

Any idea what it could be?

I will also try on cronolog.org, but their mailing list is dead.  

Med venlig hilsen / Best Regards
Tue Topholm
Device.Webbureau
M: +45 26 74 07 41
P: +45 70 21 00 04
LinkedIN: http://www.linkedin.com/in/ttopholm

-----Oprindelig meddelelse-----
Fra: Dondi M. Stroma [mailto:dstroma@verizon.net] 
Sendt: 9. november 2006 02:31
Til: modperl@perl.apache.org
Emne: Re: Mod_perl + cronolog

It seems like this is a Conolog question, not a mod_perl one. Did you not 
read http://cronolog.org/usage.html?

It says the usage is:
CustomLog "|/path/to/cronolog [OPTIONS] logfile-spec" [format]

That would mean the line in question should look more like this:
CustomLog => qq{"|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d" 
combined}

----- Original Message ----- 
From: "Tue Topholm" <tt...@device.dk>
To: "'Lupe Christoph'" <lu...@lupe-christoph.de>
Cc: <mo...@perl.apache.org>
Sent: Wednesday, November 08, 2006 1:32 PM
Subject: SV: Mod_perl + cronolog


> Hi Lupe
>
> I don't have problem with this, it works just fine...
>
>
> It is this line:
>
> CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
> combined",
>
> It gives me this failure:
>
> apachectl: Configuration syntax error, will not run "graceful":
> Syntax error on line 2 of /vhosts/vhosts.conf:
> $parms->add_config() has failed: error in condition clause at
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
> thread-multi/Apache2/PerlSections.pm line 203.\n
>
> Med venlig hilsen / Best Regards
> Tue Topholm
> Device.Webbureau
> M: +45 26 74 07 41
> P: +45 70 21 00 04
> LinkedIN: http://www.linkedin.com/in/ttopholm 




Re: Mod_perl + cronolog

Posted by "Dondi M. Stroma" <ds...@verizon.net>.
It seems like this is a Conolog question, not a mod_perl one. Did you not 
read http://cronolog.org/usage.html?

It says the usage is:
CustomLog "|/path/to/cronolog [OPTIONS] logfile-spec" [format]

That would mean the line in question should look more like this:
CustomLog => qq{"|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d" 
combined}

----- Original Message ----- 
From: "Tue Topholm" <tt...@device.dk>
To: "'Lupe Christoph'" <lu...@lupe-christoph.de>
Cc: <mo...@perl.apache.org>
Sent: Wednesday, November 08, 2006 1:32 PM
Subject: SV: Mod_perl + cronolog


> Hi Lupe
>
> I don't have problem with this, it works just fine...
>
>
> It is this line:
>
> CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
> combined",
>
> It gives me this failure:
>
> apachectl: Configuration syntax error, will not run "graceful":
> Syntax error on line 2 of /vhosts/vhosts.conf:
> $parms->add_config() has failed: error in condition clause at
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
> thread-multi/Apache2/PerlSections.pm line 203.\n
>
> Med venlig hilsen / Best Regards
> Tue Topholm
> Device.Webbureau
> M: +45 26 74 07 41
> P: +45 70 21 00 04
> LinkedIN: http://www.linkedin.com/in/ttopholm 


Re: SV: Mod_perl + cronolog

Posted by Charlie Garrison <ga...@zeta.org.au>.
Good morning,

On 8/11/06 at 7:32 PM +0100, Tue Topholm <tt...@device.dk> wrote:

>It is this line:
>
>CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
>combined",

Try using single quotes or escaping the percent characters.


Charlie

-- 
   Charlie Garrison  <ga...@zeta.org.au>
   PO Box 141, Windsor, NSW 2756, Australia

SV: Mod_perl + cronolog

Posted by Tue Topholm <tt...@device.dk>.
Hi Lupe

I don't have problem with this, it works just fine...


It is this line:

CustomLog => "|/usr/sbin/cronolog /home/log/$domain-access_log.%Y-%m-%d
combined",

It gives me this failure:

apachectl: Configuration syntax error, will not run "graceful":
Syntax error on line 2 of /vhosts/vhosts.conf:
$parms->add_config() has failed: error in condition clause at
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-
thread-multi/Apache2/PerlSections.pm line 203.\n

Med venlig hilsen / Best Regards
Tue Topholm
Device.Webbureau
M: +45 26 74 07 41
P: +45 70 21 00 04
LinkedIN: http://www.linkedin.com/in/ttopholm

-----Oprindelig meddelelse-----
Fra: Lupe Christoph [mailto:lupe@lupe-christoph.de] 
Sendt: 8. november 2006 14:43
Til: Tue Topholm
Cc: modperl@perl.apache.org
Emne: Re: Mod_perl + cronolog

On Wednesday, 2006-11-08 at 13:10:54 +0100, Tue Topholm wrote:
> I have this script:

Not related to your question, but to Perl style...

> system("/bin/mkdir /home/$domain");
> system("/bin/mkdir /home/$domain/www");
> system("/bin/mkdir /home/$domain/ErrorLog");

I think you should review perldoc perlfunc... You could also check
for errors much easier if you used the Perl functions.

> system("/bin/chown apache:apache -R /home/$domain");

And maybe File::Find. But it's only three directories, so that would
probably easier to be done in a loop with explicit values. BTW, my Linux
chown manpage says options need to precede owner:group, but the program
accepts them after owner:group, too. I'm not sure if all chowns of this
world do that...

Lupe Christoph
-- 
| You know we're sitting on four million pounds of fuel, one nuclear     |
| weapon and a thing that has 270,000 moving parts built by the lowest   |
| bidder. Makes you feel good, doesn't it?                               |
| Rockhound in "Armageddon", 1998, about the Space Shuttle               |



Re: Mod_perl + cronolog

Posted by Lupe Christoph <lu...@lupe-christoph.de>.
On Wednesday, 2006-11-08 at 13:10:54 +0100, Tue Topholm wrote:
> I have this script:

Not related to your question, but to Perl style...

> system("/bin/mkdir /home/$domain");
> system("/bin/mkdir /home/$domain/www");
> system("/bin/mkdir /home/$domain/ErrorLog");

I think you should review perldoc perlfunc... You could also check
for errors much easier if you used the Perl functions.

> system("/bin/chown apache:apache -R /home/$domain");

And maybe File::Find. But it's only three directories, so that would
probably easier to be done in a loop with explicit values. BTW, my Linux
chown manpage says options need to precede owner:group, but the program
accepts them after owner:group, too. I'm not sure if all chowns of this
world do that...

Lupe Christoph
-- 
| You know we're sitting on four million pounds of fuel, one nuclear     |
| weapon and a thing that has 270,000 moving parts built by the lowest   |
| bidder. Makes you feel good, doesn't it?                               |
| Rockhound in "Armageddon", 1998, about the Space Shuttle               |