Re: Help! About DBI in mod_perl!
This * should * work and should not cause a core dump. That said, you should take a look at the O'Rielly DBI book. There are a ton of error conditions that you're not checking here. Best to turn on RaiseError and then wrap all subsequent code in an eval block. Your code will be cleaner and easier to read, and you'll catch all possible errors. On Tue, 12 Sep 2000 [EMAIL PROTECTED] wrote: Hi all, I got the following weird problem about DBI in mod_perl. Just a simple script which can run in the "cgi-bin",but failed in the mod_perl. When I check the error_log, I find the message: [Tue Sep 12 12:01:59 2000] [notice] child pid 1273 exit signal Segmentation fault (11) My linux box: perl 5.005_03, Apache/1.3.12 (Unix) with mod_perl/1.24, DBI-1.14, Mysql 3.22.32 The http.conf about mod_perl: Alias /perl/ "/usr/local/apache/cgi-bin/" PerlTaintCheck On Location /perl AllowOverride None setenv MOD_PERL_TRACE ALL PerlSetupEnv Off SetHandler perl-script PerlHandler Apache::Registry PerlModule DBI CGI DBD::mysql PerlSetEnv PERL_DESTRUCT_LEVEL -1 Options +ExecCGI Order allow,deny Allow from all /Location The troublesome script is here: -- #!/usr/bin/perl -w use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; use DBI; use strict; my $query= new CGI; my $dsn="DBI:mysql:database=authuser;host=localhost;port=3306"; my $loginname="test"; my $password="test"; my @table; my ($dbh,$sth,$fields,$nums,$cols); print $query-header(); print $query-start_html(-title='hello'); print h3({-align='center'},"database"); print "center"; print "table border=1"; print "tr"; $dbh=DBI-connect($dsn,$loginname,$password,{RaiseError=1}) || die "Can't connect!\n"; $sth=$dbh-prepare("describe MemberAuth"); $sth-execute(); # list the column of the table $fields=$sth-fetchall_arrayref(); foreach $nums (@$fields) { foreach $cols (@$nums[0]) { print "td width=150 align=center",$cols,"/td"; } } print "/tr"; $sth=$dbh-prepare("select * from MemberAuth"); $sth-execute(); # show the records of the table while(@table=$sth-fetchrow_array()) { print "tr"; foreach my $data (@table) { print "td width=150 align=center",$data,"/td"; } print "/tr"; } $sth-finish(); $dbh-disconnect; print "/center"; print $query-end_html; --- Any help will be appreciated! -- -- Tom Mornini -- InfoMania Printing and Prepress
Re: How can I tell if Apache::ASP is available?
Hi Jason, On Wed, 13 Sep 2000, Jason wrote: This is the output of my httpd -l command .. ASP is a perl module, it's not in the output of httpd -l. how can I tell if Apache::ASP is available? Do you mean if it's in your filesystem somewhere, or if it's been loaded by mod_perl, or if you've configured it correctly? If all are true then just put something in an html file like this: HTMLHEADTITLETitle/TITLEHeading stuff./HEAD BODY % my $variable = 'This is produced by ASP.'; $ This is ordinary HTML text. %= $variable % /BODY /HTML and fetch the page with a browser. If you put PerlSetVar debug 2 in your httpd.conf then you'll get heaps of irritating (sorry Josh:) output from ASP if it's doing anything. 73, Ged.
RE: How can I tell if Apache::ASP is available?
Yes. --begin hello.asp %= "Hello World" % --end hello.asp -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 3:04 PM To: 'Jerrad Pierce' Cc: [EMAIL PROTECTED] Subject: RE: How can I tell if Apache::ASP is available? Thanks .. I typed this: [root admin]# perl use Apache::ASP; print "Hello World\n"; then pressed Ctrl-D, and it output: Hello World [root admin]# So, I assuming that means it's working. When I type lwp-request command, I get this: Connection: close Date: Wed, 13 Sep 2000 19:11:26 GMT Accept-Ranges: bytes Server: Apache/1.3.12 Cobalt (Unix) mod_ssl/2.6.4 OpenSSL/0.9.5a PHP/4.0.1pl2 mo d_auth_pam/1.0a FrontPage/4.0.4.3 mod_perl/1.24 Which I believe means that mod_perl 1.24 is installed. So by that rational, can someone on our server now program with mod_perl and Apache::ASP?? -Original Message- From: Jerrad Pierce [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 2:56 PM To: Jason Ables; [EMAIL PROTECTED] Subject: RE: How can I tell if Apache::ASP is available? prompt# perl use Apache::ASP; print "Hello World\n"; ^D If you get no errors it's there -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 2:28 PM To: [EMAIL PROTECTED] Subject: How can I tell if Apache::ASP is available? This is the output of my httpd -l command .. how can I tell if Apache::ASP is available? [admin admin]$ httpd -l bash: httpd: command not found [admin admin]$ /usr/sbin/httpd -l Compiled-in modules: http_core.c mod_so.c mod_perl.c suexec: disabled; invalid wrapper /usr/sbin/suexec [admin admin]$
RE: How can I tell if Apache::ASP is available?
I put that into an HTML file and looked at it in a browser and received this output: --begin hello.asp --end hello.asp is there something else I need to do? Thanks for all your help guys! -Original Message- From: Jerrad Pierce [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 3:12 PM To: Jason Ables; Jerrad Pierce Cc: [EMAIL PROTECTED] Subject: RE: How can I tell if Apache::ASP is available? Yes. --begin hello.asp %= "Hello World" % --end hello.asp -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 3:04 PM To: 'Jerrad Pierce' Cc: [EMAIL PROTECTED] Subject: RE: How can I tell if Apache::ASP is available? Thanks .. I typed this: [root admin]# perl use Apache::ASP; print "Hello World\n"; then pressed Ctrl-D, and it output: Hello World [root admin]# So, I assuming that means it's working. When I type lwp-request command, I get this: Connection: close Date: Wed, 13 Sep 2000 19:11:26 GMT Accept-Ranges: bytes Server: Apache/1.3.12 Cobalt (Unix) mod_ssl/2.6.4 OpenSSL/0.9.5a PHP/4.0.1pl2 mo d_auth_pam/1.0a FrontPage/4.0.4.3 mod_perl/1.24 Which I believe means that mod_perl 1.24 is installed. So by that rational, can someone on our server now program with mod_perl and Apache::ASP?? -Original Message- From: Jerrad Pierce [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 2:56 PM To: Jason Ables; [EMAIL PROTECTED] Subject: RE: How can I tell if Apache::ASP is available? prompt# perl use Apache::ASP; print "Hello World\n"; ^D If you get no errors it's there -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 13, 2000 2:28 PM To: [EMAIL PROTECTED] Subject: How can I tell if Apache::ASP is available? This is the output of my httpd -l command .. how can I tell if Apache::ASP is available? [admin admin]$ httpd -l bash: httpd: command not found [admin admin]$ /usr/sbin/httpd -l Compiled-in modules: http_core.c mod_so.c mod_perl.c suexec: disabled; invalid wrapper /usr/sbin/suexec [admin admin]$
RE: handler not quite doing what I expect
On Wed, 13 Sep 2000, Geoffrey Young wrote: My other question is about Apache::Request. Why does this: my $apr = Apache::Request-new($r); my @params = $apr-param; poon the parameters listing when it runs? If I have a page that contains three scripts as components, I need every component to get any arguments passed in. If I run the above for each component, only the first one gets the arguments. All others after that get junk. I have corrected for this by calling the code only once, but I'm curious as to whether or not this is the expected behavior and why. yes, the behavior is expected :) try Apache::RequestNotes - it uses Apache::Request during init so everyone can get to the data as many times as they want. Or alternatively changing this: sub handler { my $r = shift; ... to this: sub handler { my $r = Apache::Request-new(shift); ... Will make your life infinitely easier (Apache::Request is a subclass of Apache). -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org | AxKit: http://axkit.org
Re: Does anyone know of a Hello World program for mod_perl and Apache::ASP
Jason wrote: I need a simple script that will test to see if these are working on my server. You need to know how to work with Apache for setting up general permissions. The .htaccess file in the Apache::ASP ./site/eg folder will give you some clues. So will: http://www.apache-asp.org/install.html The ./eg folder in the distribution is where all the examples are at. -- Joshua
Apache::PerlRun::Flush
Hello all, There was some discussion about the Apache::PerlRun::Flush handler before, but here's a quick refresher: the handler was written in order to be able to run dirty code on PerlRun with PerlRunOnce Off by going through and cleaning up the memory space between each request. It's been working okay, and we're putting it through QA right now. Some people have e-mailed and asked about open sourcing of the handler, and all I can say is: It will be done, I'm just not sure when. This will be the first piece of software open sourced here at Cobalt, and it just needs to go through the right channels. By the way, is having "Apache" in the name of the package a problem? To the technical issue: One of the only problems about the handler right now is that there seems to be a strange memory leak. If I have Apache running and serving requests, if I watch the httpds on top I see them use more and more memory until it starts taxing the server. Everything seems to be working fine (variables seem to be getting flushed, etc.) but this is still happening. Does anyone have any ideas or any way to track down what variables are using up the memory? When I have Apache::Status loaded up, the Apache::ROOT* temporary PerlRun packages that get created seem to be occupying a nonzero amount of space. Is this a PerlRun bug? Please let me know if you have any idas-- I'm not on the list so please cc: me. Andrew Chen Intern, Architecture [EMAIL PROTECTED] 206-219-8445 The Cobalt Group, Inc.
Authentication and Frontpage webs
Dear Friends: I'm running the following setup: Apache/1.3.12 , with FrontPage/4.0.4.3, mod_perl/1.23, mod_ssl/2.6.3 with OpenSSL/0.9.5a on an Alpha 4100 box for our Intranet. One of the frontpage webs departments about to 'go live' has indicated that there is a rather intrincate set of users/permissions that would have to be in effect for different documents/subdirs. In the Frontpage model, this would mean that a very large number of subwebs would have to be created. All the content is pure HTML. Is there any way that we could use an authentication modules under Apache:: , together with setting up a parallel authentication database? This would let us keep using a 1 Frontpage model, along with a very flexible permissions setup. I must say that in terms of Apache:: modules, my only experience is with Apache::Sandwich. Any ideas will be greatly appreciated. Thanks in advance, Rafael Caceres
Re: Multiple Connections on Apache::DBI?
Apache::DBI overrides DBI in the creation of a connection to the database in order to cache the connection. So the connections you created below are seen as the same by Apache::DBI and when you change one you change the other since the connection is comming from the same persistent pool. Try specifying the database in the connection to make different rather than switching to it after connecting. ie: $DBI{db2} = join (":", $DBI{forum_db},$DBI{hostname}); That should create a difference between the two so Apache::DBI will keep them separate. And it also gets rid off an un-needed do() :) Good luck, Jamie On Wed, 13 Sep 2000, Mark D Wolinski wrote: Hi all, I'm using DBI to connect to a mySQL DB. I want to make two connections at the same time, as seen here: $DBI{database} = "DBI:mysql:db_a"; $DBI{hostname} = A hostname; $DBI{username} = A Username; $DBI{password} = A Password; $DBI{db} = join (":",$DBI{database},$DBI{hostname}); $db_driver = DBI-install_driver("mysql",$DBI{'username'},$DBI{'password'}); $db_master = DBI-connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, { RaiseError = 1}) || die $DBI::errstr; $DBI{forum_db} = "db_b"; $db_forums = DBI-connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, { RaiseError = 1}) || die $DBI::errstr; $db_forums-do( "use $DBI{forum_db}" ); Basically, $db_forums can be any number of different db's depending upon certain veriables, but to get a persistant connection, I'm connecting to the server and then "use"ing the correct DB. The problem that I have is that the system works fine under normal uses. However, when I run it under mod_perl and Apache_DBI, the $db_forums-do{"use $DBI{forum_db}" ); also changes the $db_master reference as well. So my question is, am I doing something wrong here? $db_master will always point to one database, but $db_forums will point to different ones. I can "use" a the correct db before each reference to it, but that seems like an awful lot of useless calls. I can't figure out why changing $db_forums would affect $db_master. Any clues are much appreciated. Mark W
Re: How can I tell if Apache::ASP is available?
This is the output of my httpd -l command .. how can I tell if Apache::ASP is available? you can't from http -l. Apache::ASP is not an apache module but a perl module. try 'perldoc Apache::ASP' if you see the documentation then Apache::ASP was properly installed. another thing, you will not be able to run microsoft asp implementation on Apache::ASP. as of the moment it just gives an easy way of embedding perl code directly into html so that you can still use your favorite html editor without it mangling your perl code. if your purpose in installing Apache::ASP is to run real microsoft asp pages, then your going the wrong direction. only NT/2000 with IIS will be able to serve asp pages. [admin admin]$ httpd -l bash: httpd: command not found [admin admin]$ /usr/sbin/httpd -l Compiled-in modules: http_core.c mod_so.c mod_perl.c suexec: disabled; invalid wrapper /usr/sbin/suexec [admin admin]$ Mike
Re: Does anyone know of a Hello World program for mod_perl andApache::ASP
On Wed, 13 Sep 2000, Jason wrote: I need a simple script that will test to see if these are working on my server. Visit the Apache::ASP homepage, there are a lot of examples there including the httpd.conf modification you may need.
Re: How can I tell if Apache::ASP is available?
"Victor Michael D. Blancas" wrote: This is the output of my httpd -l command .. how can I tell if Apache::ASP is available? you can't from http -l. Apache::ASP is not an apache module but a perl module. try 'perldoc Apache::ASP' if you see the documentation then Apache::ASP was properly installed. another thing, you will not be able to run microsoft asp implementation on Apache::ASP. as of the moment it just gives an easy way of embedding perl code directly into html so that you can still use your favorite html editor without it mangling your perl code. if your purpose in installing Apache::ASP is to run real microsoft asp pages, then your going the wrong direction. only NT/2000 with IIS will be able to serve asp pages. ASP - Active Server Pages, is a Microsoft API for web scripting, application development. VBScript is the primary language for that platform, however there is a PerlScript plugin available which Apache::ASP is fairly compatible with. If an application is writtin for IIS/PerlScript, however unlikely, then the port will be much easier to Apache::ASP. --Joshua
Logging real HTTP status
let's suppose that i want to change the HTTP status to be something other than i'm going to return from the handler(). is there a way to get the logging phase to log the status that the user-agent got rather than the return value of the handler()? here's my small script which illustrates what i'm trying to do: sub mod_perl_error { # a request object is the first argument # in handler, return mod_perl_error($r); $_[0]-status( SERVER_ERROR ); $_[0]-content_type('text/html'); $_[0]-send_http_header; $_[0]-print("There was an oopsie."); return DONE; # the log ends up with status 200 } -- brian d foy [EMAIL PROTECTED] Director of Technology, Smith Renaud, Inc. 875 Avenue of the Americas, 2510, New York, NY 10001 V: (212) 239-8985
ActivePerl mod_perl ppd available
Hi, A ppd for mod_perl, suitable for use with ActivePerls based on Perl-5.6.0, is now available. Installation is as ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/mod_perl.ppd or in ftp://theoryx5.uwinnipeg.ca/pub/ppmpackages/. A post-install script will subsequently be run which will download and install the required ApacheModulePerl.dll; this should be placed in your Apache modules directory. If for some reason the script fails, this dll can be obtained from http://theoryx5.uwinnipeg.ca/ppmpackages/. Also available in this directory is a sample Apache httpd.conf suitable to test mod_perl on Win32. This build, using VC++ 6, is based on the current cvs mod_perl version and on apache_1.3.12. If you want to compile mod_perl on your own with ActivePerl, the cvs version is known to build cleanly and pass all the tests. Also available at the above location are ppds for a few Apache-* packages; more will be added, as wants arise. Embperl is not included yet, as there's some issues that need to be sorted out first. As soon as this occurs a ppd will be made available. Although mod_perl is reasonably well tested on Win32 in general, this specific ppm version has not undergone extensive testing, and so should be considered experimental. Please report any mod_perl related bugs to the list. If you have any specific problems with installing these ppds, or would like to suggest other ppds to include, please let me know. best regards, randy kobes
cvs commit: modperl/t/net/perl dirty-script.cgi dirty-test.cgi
richter 00/09/12 23:06:53 Modified:.Changes Makefile.PL src/modules/ApacheModulePerl ApacheModulePerl.dsp t/docs startup.pl t/net/perl dirty-script.cgi dirty-test.cgi Added: src/modules/ApacheModulePerl ApacheModulePerl.def Log: Latest patches so mod_perl works now on ActivePerl Revision ChangesPath 1.515 +2 -0 modperl/Changes Index: Changes === RCS file: /home/cvs/modperl/Changes,v retrieving revision 1.514 retrieving revision 1.515 diff -u -r1.514 -r1.515 --- Changes 2000/09/01 21:09:12 1.514 +++ Changes 2000/09/13 06:06:39 1.515 @@ -15,6 +15,8 @@ fixes for ActivePerl [Gurusamy Sarathy [EMAIL PROTECTED]] +runs now on ActivePerl [Randy Korbes, Gerald Richter] + change apaci/Makefile.tmpl and src/modules/perl/Makefile so Perl's include path comes before /usr/local/include, e.g. to make sure Perl's patchlevel.h is used, thanks to Ryan Morgan for the spot 1.166 +5 -0 modperl/Makefile.PL Index: Makefile.PL === RCS file: /home/cvs/modperl/Makefile.PL,v retrieving revision 1.165 retrieving revision 1.166 diff -u -r1.165 -r1.166 --- Makefile.PL 2000/09/01 21:09:12 1.165 +++ Makefile.PL 2000/09/13 06:06:40 1.166 @@ -1170,6 +1170,11 @@ #DIR = \@DIR, NAME= "mod_perl", VERSION = $VERSION, +($] 5.005 ? () : + ( +ABSTRACT = 'Embed a Perl interpreter in the Apache HTTP server', +AUTHOR = 'Doug MacEachern [EMAIL PROTECTED]', + )), #should override `CCFLAGS', can't with older perls #CCDLFLAGS = "$Config{ccdlflags} $EXTRA_CFLAGS", DEFINE = $EXTRA_CFLAGS, 1.7 +4 -0 modperl/src/modules/ApacheModulePerl/ApacheModulePerl.dsp Index: ApacheModulePerl.dsp === RCS file: /home/cvs/modperl/src/modules/ApacheModulePerl/ApacheModulePerl.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ApacheModulePerl.dsp 2000/03/05 01:26:57 1.6 +++ ApacheModulePerl.dsp 2000/09/13 06:06:43 1.7 @@ -92,6 +92,10 @@ # End Source File # Begin Source File +SOURCE=.\ApacheModulePerl.def +# End Source File +# Begin Source File + SOURCE=..\..\..\..\..\Apache\ApacheCore.lib # End Source File # Begin Source File 1.1 modperl/src/modules/ApacheModulePerl/ApacheModulePerl.def Index: ApacheModulePerl.def === LIBRARY EXPORTS sv2request_rec perl_request_rec mod_perl_tie_table perl_cmd_perl_FLAG perl_cmd_perl_TAKE2 perl_cmd_perl_TAKE1 perl_cmd_perl_TAKE123 perl_perl_cmd_cleanup 1.38 +3 -1 modperl/t/docs/startup.pl Index: startup.pl === RCS file: /home/cvs/modperl/t/docs/startup.pl,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- startup.pl2000/05/12 07:10:58 1.37 +++ startup.pl2000/09/13 06:06:46 1.38 @@ -11,7 +11,9 @@ use lib map { "$Apache::Server::CWD/$_" } qw(t/docs blib/lib blib/arch); require "blib.pl" if -e "./t/docs/blib.pl"; #Perl ignores w/ -T -unshift @INC, split ":", $ENV{PERL5LIB} if $ENV{PERL5LIB}; +if ($ENV{PERL5LIB} and $ENV{PASS_PERL5LIB}) { + unshift @INC, map { Apache-untaint($_) } split ":", $ENV{PERL5LIB}; +} $Apache::Server::Starting or warn "Server is not starting !?\n"; \$Apache::Server::Starting == \$Apache::ServerStarting or 1.6 +5 -1 modperl/t/net/perl/dirty-script.cgi Index: dirty-script.cgi === RCS file: /home/cvs/modperl/t/net/perl/dirty-script.cgi,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- dirty-script.cgi 2000/05/12 07:10:59 1.5 +++ dirty-script.cgi 2000/09/13 06:06:48 1.6 @@ -1,6 +1,10 @@ local $^W = 0; -use lib '.'; +unshift @INC, + -e "dirty-lib" ? '.' : + Apache-server_root_relative("net/perl"); require "dirty-lib"; +shift @INC; + unless (defined(not_ina_package) not_ina_package()) { die "%INC save/restore broken"; } 1.6 +6 -1 modperl/t/net/perl/dirty-test.cgi Index: dirty-test.cgi === RCS file: /home/cvs/modperl/t/net/perl/dirty-test.cgi,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- dirty-test.cgi
cvs commit: modperl Changes
dougm 00/09/13 00:48:56 Modified:.Changes Log: fix order and randy's name Revision ChangesPath 1.516 +2 -2 modperl/Changes Index: Changes === RCS file: /home/cvs/modperl/Changes,v retrieving revision 1.515 retrieving revision 1.516 diff -u -r1.515 -r1.516 --- Changes 2000/09/13 06:06:39 1.515 +++ Changes 2000/09/13 07:48:55 1.516 @@ -10,12 +10,12 @@ =item 1.24_01-dev +fixes to run and pass 'make test' on ActivePerl [Randy Kobes, Gerald Richter] + Makefile.PL:post_initialize fix for win32, thanks to john sterling for the spot fixes for ActivePerl [Gurusamy Sarathy [EMAIL PROTECTED]] - -runs now on ActivePerl [Randy Korbes, Gerald Richter] change apaci/Makefile.tmpl and src/modules/perl/Makefile so Perl's include path comes before /usr/local/include, e.g. to make sure Perl's