You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Manuel Blechschmidt <ma...@gmx.de> on 2005/10/29 18:46:05 UTC
[users@httpd] RewriteMap in Perl with other Environment Variables
Hello List,
I just wrote a little script which should check URLs from the databse if
they are correct.
That works fine. But I wasn't able to tell the script to run with other
environment variables.
The Perl that I use is a custom build of a software system that we use.
Here are the sources of the script:
#!/usr/local/epages5/eproot/Perl/bin/perl
require 5.000;
require Exporter;
@ISA = qw ( Exporter );
use DBI;
use utf8;
use Naturideen::Erweiterung2::API::TLE::MyFormatter;
$| = 0;
#----------------------
# Enter DB-Data
#----------------------
$user1="sa";
$pw1="*****";
$db1="storedb";
$sql1="DBServer";
my $dbi = DBI->connect("dbi:Sybase:server=$sql1;database=$db1",
$user1,$pw1);
my $sql = "SELECT lsa.value, manufacturer,alias FROM product, object,
localizedstringattribute lsa WHERE lsa.languageid = 1 and lsa.objectid =
object.objectid and lsa.attributeid = 1757 and product.productid =
object.objectid and alias = ?";
my $sth = $dbi->prepare($sql);
my $format = new Naturideen::Erweiterung2::API::TLE::MyFormatter;
while(<STDIN>) {
# Fetch the Alias from the URL
/.*-((MA-\d{6})|(\d\d\d\d\d-(\d\d\d?\d?|\w)))/;
# Get the the infos from the database
$sth->execute($1);
my ($name, $manufacturer, $alias) = $sth->fetchrow_array;
my $url = $format->Format(undef, 'sonder', $name,
undef).($format->Format(undef, 'sonder', $name, undef) ne '' ?
'-'.$format->Format(undef, 'sonder', $manufacturer, undef) :
'').'-'.$alias."\n";
if($url eq $_) {
print 'Products/'.$1."\n";
} else {
print '404'."\n";
}
}
$dbi->disonnect;
1;
That works fine.
Here is the conf:
RewriteMap productmap prg:/usr/local/epages5/eproot/Scripts/rewrite.pl
RewriteRule ^/(.*-((MA-\d{6})|(\d\d\d\d\d-(\d\d\d?\d?|\w))))
${productmap:$1}
And here is the error from the apache Log:
Can't locate DBI.pm in @INC (@INC contains:
/home/root-epages-install/Perl/lib/linux
/home/root-epages-install/Perl/lib
/home/root-epages-install/Perl/lib/site_perl/linux
/home/root-epages-install/Perl/lib/site_perl
/home/root-epages-install/Perl/lib/site_perl .) at
/usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
BEGIN failed--compilation aborted at
/usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
Can't locate DBI.pm in @INC (@INC contains:
/home/root-epages-install/Perl/lib/linux
/home/root-epages-install/Perl/lib
/home/root-epages-install/Perl/lib/site_perl/linux
/home/root-epages-install/Perl/lib/site_perl
/home/root-epages-install/Perl/lib/site_perl .) at
/usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
BEGIN failed--compilation aborted at
/usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
In the moment I am trying getting this to work with the native Perl.
Greetings
Manuel
--
HybridWorx - Puxbaumer & Blechschmidt GbR
Manuel Blechschmidt
Julius-Posener-Str. 1
14478 Potsdam
Mobil: 0179/4644688
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] RewriteMap in Perl with other Environment Variables
Posted by Manuel Blechschmidt <ma...@gmx.de>.
Hello
allan juul wrote:
> Manuel Blechschmidt wrote:
>
>> Hello List,
>> I just wrote a little script which should check URLs from the databse
>> if they are correct.
>> That works fine. But I wasn't able to tell the script to run with
>> other environment variables.
>> The Perl that I use is a custom build of a software system that we use.
>> Here are the sources of the script:
>
>
> [snip]
>
>> And here is the error from the apache Log:
>> Can't locate DBI.pm in @INC (@INC contains:
>> /home/root-epages-install/Perl/lib/linux
>> /home/root-epages-install/Perl/lib
>> /home/root-epages-install/Perl/lib/site_perl/linux
>> /home/root-epages-install/Perl/lib/site_perl
>> /home/root-epages-install/Perl/lib/site_perl .) at
>> /usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
>
>
>
> i'm surprised if that perl script works, since the error indicates
> that you miss the DBI.pm package ?
No it doesn't work inside apache. Now I could solve the problem. I set
some variables in the script and took another build of perl.
>
> can you actuallty run the script from the command line and it works ?
>
> ./a
Yes this worked
>
>
Greetings and thx for your help.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] RewriteMap in Perl with other Environment Variables
Posted by allan juul <al...@muly.dk>.
Manuel Blechschmidt wrote:
> Hello List,
> I just wrote a little script which should check URLs from the databse if
> they are correct.
> That works fine. But I wasn't able to tell the script to run with other
> environment variables.
> The Perl that I use is a custom build of a software system that we use.
> Here are the sources of the script:
[snip]
> And here is the error from the apache Log:
> Can't locate DBI.pm in @INC (@INC contains:
> /home/root-epages-install/Perl/lib/linux
> /home/root-epages-install/Perl/lib
> /home/root-epages-install/Perl/lib/site_perl/linux
> /home/root-epages-install/Perl/lib/site_perl
> /home/root-epages-install/Perl/lib/site_perl .) at
> /usr/local/epages5/eproot/Scripts/rewrite.pl line 6.
i'm surprised if that perl script works, since the error indicates that
you miss the DBI.pm package ?
can you actuallty run the script from the command line and it works ?
./a
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org