Re: [OT] Wanted: beginning perl books for poor kids
What open-source geek doesn't understand the importance, and calling, of supporting your community? Count me in. I think it's great that you are donating your time and patience. Teaching isn't easy, but you've got a great cause. Send me your shipping address and I'll send you a Llama book. http://www.rain.org/~artworks/NewATW/students/norma_web/sonar.html is striking. I hope this girl goes on to great things. -- Ryan - Original Message - From: Nick Tonkin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 31, 2002 9:57 PM Subject: [OT] Wanted: beginning perl books for poor kids Hi all, I am going to be working with a small group of disadvantaged youngsters here teaching them how to build web applications with perl and apache. These are mostly Latino kids who have been doing analog and digital art for years and have self-selected into webmastering, html-ing and such. I'm excited to get them going in perl, and I want to appeal to the list for donations of books on learning perl. Of course I'm most hopeful that we can get half a dozen copies of the Llama book and use it as a sort of textbook, but anything will be gratefully accepted. An existing site that shows some of the art these kids make (and also why we need a new one!) can be viewed at http://www.rain.org/~artworks/ A cool project by one of the students is at http://www.rain.org/%7Eartworks/NewATW/students/norma_web/norma_intro.html Thanks folks, - nick Nick Tonkin {|8^)
Re: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn't work
If you have an access handler return OK, then the access handling stops. Because that handler handled it. So as far as I know: $r-push_handlers('PerlAuthenHandler', 'Some::handler'); return DECLINED; should work... -- Ryan - Original Message - From: Rodney Broom [EMAIL PROTECTED] To: mod_perl list [EMAIL PROTECTED] Sent: Saturday, August 31, 2002 6:59 PM Subject: $r-push_handlers('PerlAuthenHandler', 'Some::handler') doesn't work Hi all, I'm sure I'm just missing something, but I'm stumped. I've got an access handler that does some tests and then conditionaly does this: $r-push_handlers('PerlAuthenHandler', 'Some::handler'); return OK; Some::handler() starts by printing the current callback to the error log, which never happens if it's set to run in the 'PerlAuthenHandler'. If I change the push_handlers() to use 'PerlFixupHandler', then Some::handler() gets called and I see it in the error log. What am I doing wrong? I know it has to be me. --- Rodney Broom President, R.Broom Consulting http://www.rbroom.com/
My autoresponder
All who have recently posted on this list: You have been receiving my auto-responder, which I set up to make sure any of my customer's knew why they weren't getting a response. In a very hurriedly and obviously clueless manner I forgot to exclude this list, or even temporarily un-subscribe. I'm genuinely sorry for everyone receiving spam after spam from me. -- Ryan Parr (aka [EMAIL PROTECTED])
Re: Persistant references [was] Persistent Net::Telnet Objects
I have thought about this, and it's something I'm willing to do if I have to. I would much rather be able to store an actual code ref and avoid the overhead of many string-form eval's. Is there no way to do this? -- Ryan - Original Message - From: Garth Winter Webb [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 11:16 PM Subject: Re: Persistant references [was] Persistent Net::Telnet Objects You could just pass around a string rather than a subref: my $handler = 'sub { my $arg = @_; do_something(); }'; vs my $handler = sub { my $arg = @_; do_something(); }; When you want to call it later on you do it like: eval($handler)-('foo'); vs $handler-('foo'); Garth On Wed, 2002-05-29 at 22:17, Ryan Parr wrote: I never do give enough info on the first e-mail. Thank you for bearing with me... What I mean is, if a request comes in for a certain form I would like to be able to do something like this: my $form = load_form($r); $c{$session_id}-{handler} = $form-{handler}; # -- this being a code ref... $r-send_http_header; print $form; Then when the user completes the form and resubmits: my $handler = $c{$session_id}-{handler}; $r-send_http_header; print $handler-($r); This is definately simplified, but the idea is there. I would like to be able to store anything that can be referenced and have it be available to all processes. I would like to be able to dynamically create anonymous subroutine handlers based on input and have them be active until the form is submitted, at which time they are used to process the form then discarded. Is this something that can be accomplished? The global hash using Perl aliasing (http://thingy.kcilink.com/modperlguide/perl/Using_the_Perl_Aliasing_Feature _.html) works beautifully, until of course the form is submitted to another httpd process, and I'm hoping to not have to limit myself to just one child. Obviously this can't be serialized, but there has to be *some* way to do this... -- Ryan - Original Message - From: Ryan Parr [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 9:16 PM Subject: Persistant references [was] Persistent Net::Telnet Objects Along these same lines I'm seeking a way to store a code reference into a global hash that is shared among all processes. For example: my $session_id = get_session_from_cookie($r); my $handler = $c{$session_id}-{handler}; $r-send_http_header; print $handler-($r); return OK; Has anyone performed this kind of magical tidbit before? Is there some main process repository that I can access? -- Ryan - Original Message - From: Rob Mueller (fastmail) [EMAIL PROTECTED] To: French, Shawn [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 5:35 PM Subject: Re: Persistent Net::Telnet Objects Our project needed persistent socket connections open as well. There is supposed to be a standard mechanism to pass file descriptors between unix processes, though it's bugginess level depends on your OS. There is a perl module for this called Socket::PassAccessRights. So what you can do is create a daemon process that just hangs round holding socket connections open, like a socket cache basically, and passing them back and forth between Apache processes based on some session ID or user ID or the like. Your daemon ends up looking something like this (with lots more error checking of course) my %sockmap; while (1) { my $clientsock = $listen-accept(); chomp(my $sessionid = $clientsock); my $cachesock = ($sockmap{$sessionid} ||= opennewsock()); Socket::PassAccessRights::sendfd(fileno($clientsock), fileno($cachesock)); $clientsock-close(); } And in your mod_perl code you do something like: my $serversock = IO::Socket::INET-new(Server = 'localhost', Port = SOCKETPOOLPORT); print $serversock $sessionid, \n; my $Fd = Socket::PassAccessRights::recvfd(fileno($serversock)); open(my $realsocket, =$Fd); fcntl($realsocket, F_SETFD, 0); my $ofh = select($realsocket); $| = 1; select ($ofh); If you do some experimenting, you'll get something that works, you'll also find lots of cases that don't. Rob - Original Message - From: French, Shawn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 30, 2002 3:53 AM Subject: Persistent Net::Telnet Objects Vitals: Apache/1.3.20 (Win32) mod_perl/1.25_01-dev mod_ssl/2.8.4 OpenSSL/0.9.6a on Windows 2000 with PHP 4.21 I am working on a project that requires me to have two telnet objects per user session opened, and accessible throughout the user's session. I have looked at Apache::Session and many other solutions
Re: Persistant references [was] Persistent Net::Telnet Objects
I never do give enough info on the first e-mail. Thank you for bearing with me... What I mean is, if a request comes in for a certain form I would like to be able to do something like this: my $form = load_form($r); $c{$session_id}-{handler} = $form-{handler}; # -- this being a code ref... $r-send_http_header; print $form; Then when the user completes the form and resubmits: my $handler = $c{$session_id}-{handler}; $r-send_http_header; print $handler-($r); This is definately simplified, but the idea is there. I would like to be able to store anything that can be referenced and have it be available to all processes. I would like to be able to dynamically create anonymous subroutine handlers based on input and have them be active until the form is submitted, at which time they are used to process the form then discarded. Is this something that can be accomplished? The global hash using Perl aliasing (http://thingy.kcilink.com/modperlguide/perl/Using_the_Perl_Aliasing_Feature _.html) works beautifully, until of course the form is submitted to another httpd process, and I'm hoping to not have to limit myself to just one child. Obviously this can't be serialized, but there has to be *some* way to do this... -- Ryan - Original Message - From: Ryan Parr [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 9:16 PM Subject: Persistant references [was] Persistent Net::Telnet Objects Along these same lines I'm seeking a way to store a code reference into a global hash that is shared among all processes. For example: my $session_id = get_session_from_cookie($r); my $handler = $c{$session_id}-{handler}; $r-send_http_header; print $handler-($r); return OK; Has anyone performed this kind of magical tidbit before? Is there some main process repository that I can access? -- Ryan - Original Message - From: Rob Mueller (fastmail) [EMAIL PROTECTED] To: French, Shawn [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 5:35 PM Subject: Re: Persistent Net::Telnet Objects Our project needed persistent socket connections open as well. There is supposed to be a standard mechanism to pass file descriptors between unix processes, though it's bugginess level depends on your OS. There is a perl module for this called Socket::PassAccessRights. So what you can do is create a daemon process that just hangs round holding socket connections open, like a socket cache basically, and passing them back and forth between Apache processes based on some session ID or user ID or the like. Your daemon ends up looking something like this (with lots more error checking of course) my %sockmap; while (1) { my $clientsock = $listen-accept(); chomp(my $sessionid = $clientsock); my $cachesock = ($sockmap{$sessionid} ||= opennewsock()); Socket::PassAccessRights::sendfd(fileno($clientsock), fileno($cachesock)); $clientsock-close(); } And in your mod_perl code you do something like: my $serversock = IO::Socket::INET-new(Server = 'localhost', Port = SOCKETPOOLPORT); print $serversock $sessionid, \n; my $Fd = Socket::PassAccessRights::recvfd(fileno($serversock)); open(my $realsocket, =$Fd); fcntl($realsocket, F_SETFD, 0); my $ofh = select($realsocket); $| = 1; select ($ofh); If you do some experimenting, you'll get something that works, you'll also find lots of cases that don't. Rob - Original Message - From: French, Shawn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 30, 2002 3:53 AM Subject: Persistent Net::Telnet Objects Vitals: Apache/1.3.20 (Win32) mod_perl/1.25_01-dev mod_ssl/2.8.4 OpenSSL/0.9.6a on Windows 2000 with PHP 4.21 I am working on a project that requires me to have two telnet objects per user session opened, and accessible throughout the user's session. I have looked at Apache::Session and many other solutions but my problem is that to keep a Net::Telnet object, I need to keep open sockets and filehandles, so I cannot serialize the object and store it in a database or file. Currently I have similar code working flawlessly: ### # startup.pl - called when apache starts (ie. PerlRequire d:/Apache/conf/startup.pl) ## use MySite::Session; ### # Session.pm ## @EXPORT = qw( %sessionHash ); our %sessionHash; ### # init_session.pl - called IN MOD_PERL when a new session is requested ## use MySite::Session; $sessionHash{$session_id . _telnetObj} = Net::Telnet-new(); ### # dostuff.pl - called IN MOD_PERL many time throughout the session ## use MySite::Session; my telnetObj = $sessionHash{$session_id . _telnetObj}; bless (\$telnetObj, Net::Telnet); Although this is working right now, I don't know enough [ anything? :) ] about Apache or mod_perl to be sure that this will work in the future. What I am really concerned
Re: libperl.so vs mod_perl.so
I didn't know about that script :) I'm glad to know it's out there. Using the ports *would* make life much easier. Thanks! -- Ryan - Original Message - From: Doug Silver [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: mod_perl Mailing List [EMAIL PROTECTED] Sent: Thursday, April 11, 2002 4:45 PM Subject: Re: libperl.so vs mod_perl.so Ryan - I upgraded to perl 5.6 and when I built mod_perl it used the right one, I would guess that it would only build it against 5.0 if you didn't run the `use.perl {port,system}` script that comes with perl 5.6. The last time I read about loadable modules vs compiled said that the loadable route costs during startup, but beyond that it's nearly a push. Using the ports system makes upgrading Apache and all the other system software much easier than the other route. But, everyone does things differently, so YMMV! ~~ Doug Silver Network Manager Urchin Corporation http://www.urchin.com ~~ On Thu, 11 Apr 2002, Ryan Parr wrote: As a fellow FreeBSD user (4.5) I recommend building Apache and mod_perl from source. The ports version builds against the default Perl version (5.005), even if you upgrade. Therefore, that's all you get in your mod_perl. Also, it's a good idea to compile mod_perl into Apache, at least, that's what everyone on this list seems to say... To get the same layout as with the port install configure apache --with-layout=FreeBSD -- Ryan - Original Message - From: Ged Haywood [EMAIL PROTECTED] To: Mike Loiterman [EMAIL PROTECTED] Cc: mod_perl Mailing List [EMAIL PROTECTED] Sent: Thursday, April 11, 2002 4:24 PM Subject: Re: libperl.so vs mod_perl.so Hi there, On Thu, 11 Apr 2002, Mike Loiterman wrote: -BEGIN PGP SIGNED MESSAGE- There's really no need for all this... :) but there is no entry for LoadModule /libexec/apache/mod_perl.so That's because mod_perl.so doesn't exist. There is a an entry for libperl.so and there is a file called libperl.so. That's the one! How can I quickly and easily test if mod_perl is inded installed Read the Guide some more... http://perl.apache.org/guide ... and check the error_log. 73, Ged.
Re: libperl.so vs mod_perl.so
As a fellow FreeBSD user (4.5) I recommend building Apache and mod_perl from source. The ports version builds against the default Perl version (5.005), even if you upgrade. Therefore, that's all you get in your mod_perl. Also, it's a good idea to compile mod_perl into Apache, at least, that's what everyone on this list seems to say... To get the same layout as with the port install configure apache --with-layout=FreeBSD -- Ryan - Original Message - From: Ged Haywood [EMAIL PROTECTED] To: Mike Loiterman [EMAIL PROTECTED] Cc: mod_perl Mailing List [EMAIL PROTECTED] Sent: Thursday, April 11, 2002 4:24 PM Subject: Re: libperl.so vs mod_perl.so Hi there, On Thu, 11 Apr 2002, Mike Loiterman wrote: -BEGIN PGP SIGNED MESSAGE- There's really no need for all this... :) but there is no entry for LoadModule /libexec/apache/mod_perl.so That's because mod_perl.so doesn't exist. There is a an entry for libperl.so and there is a file called libperl.so. That's the one! How can I quickly and easily test if mod_perl is inded installed Read the Guide some more... http://perl.apache.org/guide ... and check the error_log. 73, Ged.
Re: Can't open perl script -spi.bak
On FreeBSD using Perl 5.6.1: perl -e 'system(ls,-d,/);'-- This works, showing just / perl -e 'system(ls, -d,/);' -- This fails, showing ls: -d: No such file or directory On FreeBSD using tcsh: perldoc -f system-- This works perldoc -f system -- The shell sees that it doesn't start with a - and interperets it as a module to look up documentation for. On Win2K using cmd: dir C:\-- This works dir C:\ -- Again, same issue, The filename, directory name, or volume label syntax is incorrect I think that this is pretty standard behaviour, and will be seen in various examples on multiple system. I also think that this is indeed desirable. -- Ryan - Original Message - From: Randy Kobes [EMAIL PROTECTED] To: Garth Winter Webb [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, March 22, 2002 5:43 PM Subject: Re: Can't open perl script -spi.bak On 22 Mar 2002, Garth Winter Webb wrote: On Fri, 2002-03-22 at 12:57, Robert Landrum wrote: That's is very weird, because this code doesn't seem to work: perl -e 'system(perl, -e1) == 0 or die oops' Actually, that's not all that weird. Most shells take care of stripping out garbage before setting the argument list. Since system(LIST) doesn't use the shell, it's passing perl the literal -e1 which perl won't recognize as a command line option (and correctly so in my opinion). Actually this isn't standard behavior. I can't think of a situation where I would want to use system to concatanate a string for me rather than interpreting the string as an argument and act accordingly. If you check 'perldoc -f system', this is exactly what system is supposed to do when given a program name and a list of arguments, so it looks like 'systetm' may be buggy in the win32 version of perl This behaviour seems to be dependent on the Perl version and on the Win32 shell used - the leading whitespace in front of the 1st argument after the program name in the system() call didn't cause a problem on Windows 98 with ActivePerl 626 (which I used to develop that part of the Makefile.PL), but it does cause a problem on other Win32s with different ActivePerl versions. best regards, randy kobes
[OT] Re: Can't open perl script -spi.bak
I also think that there me some mis-interpretation here of the system docs: snip src=cmd:perldoc -f system If there is more than one argument in LIST, or if LIST is an array with more than one value, starts the program given by the first element of the list with arguments given by the rest of the list. If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is C/bin/sh -c on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to Cexecvp, which is more efficient. /snip Basically this says that : system('ls','-d','/'); skips the shell system('ls -d /'); is broken into words and skips the shell and system('ls -d /*'); is passed to the shell as one big string. system('ls -d /*'); of course is the same After reading this I wasn't sure how it would handle: system('ls','-d','/*'); since it's more than one argument but with shell metacharacters... I assumed it would go to the shell... But I was wrong. It doesn't go to the shell for metacharacter interpretation and it reports: ls: /*: No such file or directory Therefore it's safe to say that no string concatenation is done, and it makes sense that ' -el' is not a valid argument. -- Ryan - Original Message - From: Ryan Parr [EMAIL PROTECTED] To: Randy Kobes [EMAIL PROTECTED]; Garth Winter Webb [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, March 22, 2002 9:55 PM Subject: Re: Can't open perl script -spi.bak On FreeBSD using Perl 5.6.1: perl -e 'system(ls,-d,/);'-- This works, showing just / perl -e 'system(ls, -d,/);' -- This fails, showing ls: -d: No such file or directory On FreeBSD using tcsh: perldoc -f system-- This works perldoc -f system -- The shell sees that it doesn't start with a - and interperets it as a module to look up documentation for. On Win2K using cmd: dir C:\-- This works dir C:\ -- Again, same issue, The filename, directory name, or volume label syntax is incorrect I think that this is pretty standard behaviour, and will be seen in various examples on multiple system. I also think that this is indeed desirable. -- Ryan - Original Message - From: Randy Kobes [EMAIL PROTECTED] To: Garth Winter Webb [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, March 22, 2002 5:43 PM Subject: Re: Can't open perl script -spi.bak On 22 Mar 2002, Garth Winter Webb wrote: On Fri, 2002-03-22 at 12:57, Robert Landrum wrote: That's is very weird, because this code doesn't seem to work: perl -e 'system(perl, -e1) == 0 or die oops' Actually, that's not all that weird. Most shells take care of stripping out garbage before setting the argument list. Since system(LIST) doesn't use the shell, it's passing perl the literal -e1 which perl won't recognize as a command line option (and correctly so in my opinion). Actually this isn't standard behavior. I can't think of a situation where I would want to use system to concatanate a string for me rather than interpreting the string as an argument and act accordingly. If you check 'perldoc -f system', this is exactly what system is supposed to do when given a program name and a list of arguments, so it looks like 'systetm' may be buggy in the win32 version of perl This behaviour seems to be dependent on the Perl version and on the Win32 shell used - the leading whitespace in front of the 1st argument after the program name in the system() call didn't cause a problem on Windows 98 with ActivePerl 626 (which I used to develop that part of the Makefile.PL), but it does cause a problem on other Win32s with different ActivePerl versions. best regards, randy kobes
Re: [OT] Thought for the Day
John mentions /usr/games/fortune -o, which will print offensive messages. They are quite funny though. To use it without offensive messages (just funny ones) just don't pass it options. - Original Message - From: John Eisenschmidt [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, March 10, 2002 1:37 PM Subject: Re: [OT] Thought for the Day
Re: [OT] Thought for the Day
I have the exact same thing set up for my website. Just without the dogma of course :) I'm thinking that I'll have to collect plenty of Deep Thoughts, to change the general tone of my site. -- Ryan - Original Message - From: John Eisenschmidt [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, March 11, 2002 2:46 PM Subject: Re: [OT] Thought for the Day
Re: Configuration problem -- HTML embeded cgi script calls not working [using default MDK/Linux 8.1 (Apache 1.3)]
http://httpd.apache.org/docs/howto/ssi.html#configuringyourservertopermitssi for more information than I'm writing out... You need to have (somewhere in the main configuration section) the following: # # To use server-parsed HTML files # AddType text/html .shtml AddHandler server-parsed .shtml Then make the suffix of your files .shtml. You can do: AddType text/html .shtml AddHandler server-parsed .shtml .html .htm to make all of your files be server-parsed. This can be a huge slowdown if your site gets many hits. You can take out the Location /index.shtml altogether. Also, in your /cgi-bin alias, don't do Options ExecCGI even though that probably works fine. You might be better off with the following: # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the realname directory are treated as applications and # run by the server when requested rather than as documents sent to the client. # The same rules about trailing / apply to ScriptAlias directives as to # Alias. # ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Directory /var/www/cgi-bin AllowOverride None Options None Order allow,deny Allow from all /Directory One of the bad things about having a regular Directory setting without the ScriptAlias, and just turning on Options ExecCGI is that the directory will be browseable by default. Meaning that I could just go to http://yourserver/cgi-bin and view all the CGI's in your directory, and maybe (too tired to test) view their contents. Make sure you put always put an ending / on your script alias definition. -- Ryan - Original Message - From: Ivica Bukvic [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 1:46 AM Subject: Configuration problem -- HTML embeded cgi script calls not working [using default MDK/Linux 8.1 (Apache 1.3)] Hi all, I am a self-taught Linux admin, working hard on patching my knowledge potholes. One of them is Apache/cgi/perl configuration. I am using Mandrake 8.1 on an Intel machine, that comes pre-installed with Apache 1.3. Default configuration file (/etc/httpd/conf/commonhttpd.conf) looks as follows (only the last part that pertains to this issue, I hope :-) ): # This should be changed to whatever you set DocumentRoot to. # Directory /var/www/html # # This may also be None, All, or any combination of Indexes, # Includes, FollowSymLinks, ExecCGI, or MultiViews. # # Note that MultiViews must be named *explicitly* --- Options All # doesn't give it to you. # Options Indexes FollowSymLinks MultiViews # # This controls which options the .htaccess files in directories can # override. Can also be All, or any combination of Options, FileInfo, # AuthConfig, and Limit # AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all /Directory Directory /var/www/perl AllowOverride All #Options Indexes FollowSymLinks MultiViews ExecCGI Options FollowSymLinks MultiViews ExecCGI Order allow,deny Allow from all /Directory Directory /var/www/cgi-bin AllowOverride All Options Includes ExecCGI /Directory Directory /var/www/protected-cgi-bin AllowOverride None Options ExecCGI Order deny,allow Deny from all Allow from 127.0.0.1 #allow from .your_domain.com /Directory # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # #Directory /home/*/public_html #AllowOverride FileInfo AuthConfig Limit #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec #Limit GET POST OPTIONS PROPFIND #Order allow,deny #Allow from all #/Limit #LimitExcept GET POST OPTIONS PROPFIND #Order deny,allow #Deny from all #/LimitExcept #/Directory # These settings are pretty flexible, and allow for Frontpage and XSSI Directory /Users/*/public_html AllowOverride All Options MultiViews Indexes Includes FollowSymLinks Order allow,deny Allow from all /Directory #Directory /Users/*/public_html/cgi-bin #AllowOverride All #Options ExecCGI #SetHandler cgi-script #/Directory IfModule mod_perl.c Directory /Users/*/public_html/cgi-bin SetHandler perl-script PerlHandler Apache::PerlRun Options -Indexes ExecCGI PerlSendHeader On /Directory /IfModule Directory /var/www/icons Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all /Directory Directory /usr/share/doc Options Indexes FollowSymLinks Order deny,allow Deny from all Allow from 127.0.0.1 #allow from .your_domain.com /Directory Location /index.shtml Options +Includes /Location IfModule
Re: Configuration problem -- HTML embeded cgi script calls not working [using default MDK/Linux 8.1 (Apache 1.3)]
Oh yeah: To make your scripts output more sensible information to the screen/error logs you can put the following use statement at the top of the CGI: #!perl -w use strict; use CGI::Carp qw(fatalsToBrowser); CGI::Carp will make sure that actual Perl errors go to your browser and error log. Also, try running your scripts from the command line as such perl -c script.cgi before trying to actually run them. The -c option tells Perl to compile without actually running. It can save you alot of time. If you've downloaded the scripts from some online Perl-CGI repository than use strict; will most-likely break the script, and -w will most likely fill your logs with crap you're not looking to find. But they can help out alot if you're looking to write clean scripts. Basically if you're sure that you're sending the appropriate headers (Content-type: text/html\n\n) before you print to STDOUT, then your script is probably dying prematurely without spitting out any content at all. Hopefully perl -c script.cgi will tell you why. If not then you may want to resort to putting * print STDERR Reached line: ,__LINE__,\n; * at strategic areas in your script so you know how far it's getting in execution before it's untimely demise. -- Ryan - Original Message - From: Ryan Parr [EMAIL PROTECTED] To: Ivica Bukvic [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 3:18 AM Subject: Re: Configuration problem -- HTML embeded cgi script calls not working [using default MDK/Linux 8.1 (Apache 1.3)] http://httpd.apache.org/docs/howto/ssi.html#configuringyourservertopermitssi for more information than I'm writing out... You need to have (somewhere in the main configuration section) the following: # # To use server-parsed HTML files # AddType text/html .shtml AddHandler server-parsed .shtml Then make the suffix of your files .shtml. You can do: AddType text/html .shtml AddHandler server-parsed .shtml .html .htm to make all of your files be server-parsed. This can be a huge slowdown if your site gets many hits. You can take out the Location /index.shtml altogether. Also, in your /cgi-bin alias, don't do Options ExecCGI even though that probably works fine. You might be better off with the following: # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the realname directory are treated as applications and # run by the server when requested rather than as documents sent to the client. # The same rules about trailing / apply to ScriptAlias directives as to # Alias. # ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Directory /var/www/cgi-bin AllowOverride None Options None Order allow,deny Allow from all /Directory One of the bad things about having a regular Directory setting without the ScriptAlias, and just turning on Options ExecCGI is that the directory will be browseable by default. Meaning that I could just go to http://yourserver/cgi-bin and view all the CGI's in your directory, and maybe (too tired to test) view their contents. Make sure you put always put an ending / on your script alias definition. -- Ryan - Original Message - From: Ivica Bukvic [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 1:46 AM Subject: Configuration problem -- HTML embeded cgi script calls not working [using default MDK/Linux 8.1 (Apache 1.3)] Hi all, I am a self-taught Linux admin, working hard on patching my knowledge potholes. One of them is Apache/cgi/perl configuration. I am using Mandrake 8.1 on an Intel machine, that comes pre-installed with Apache 1.3. Default configuration file (/etc/httpd/conf/commonhttpd.conf) looks as follows (only the last part that pertains to this issue, I hope :-) ): # This should be changed to whatever you set DocumentRoot to. # Directory /var/www/html # # This may also be None, All, or any combination of Indexes, # Includes, FollowSymLinks, ExecCGI, or MultiViews. # # Note that MultiViews must be named *explicitly* --- Options All # doesn't give it to you. # Options Indexes FollowSymLinks MultiViews # # This controls which options the .htaccess files in directories can # override. Can also be All, or any combination of Options, FileInfo, # AuthConfig, and Limit # AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all /Directory Directory /var/www/perl AllowOverride All #Options Indexes FollowSymLinks MultiViews ExecCGI Options FollowSymLinks MultiViews ExecCGI Order allow,deny Allow from all /Directory Directory /var/www/cgi-bin AllowOverride All Options Includes ExecCGI /Directory Directory /var/www/protected-cgi
Re: mod_perl, mod_gzip, incredible suckage
Wow, I'm having a hell of a time with it too. I compiled it directly into Apache. I don't get segfaults but I don't get compression either. After all the time I've put into it (it's late, and now I'm drunk) I could compose a lovely rant on this, but I'll keep that to myself. No love. I get no love from mod_gzip. -- Ryan - Original Message - From: Mithun Bhattacharya [EMAIL PROTECTED] To: ModPerl List [EMAIL PROTECTED] Sent: Thursday, February 14, 2002 10:10 PM Subject: Re: mod_perl, mod_gzip, incredible suckage Robin Berjon wrote: I got it to work once, but I confirm this was painful. I don't use it anymore though so I can't remember the magic that it took to get it to run. As an alternative (probably incomplete) solution, you might want to look inside one of the templating/publishing modules out there that support gzip output natively. I know AxKit does, and iirc TT does too (but I'm not sure). http://www.egurucool.com Works fine with mod_gzip as a DSO Dont even recall having to do anything fancy just followed the documentation. Mithun
Re: Question...
I think I'm missing something... If you set a session cookie (i.e. one with no expiry time) then the cookie will be deleted immediately upon browser close, forcing the user to login again if they've closed their browser instance. If you don't use cookies and allow basic auth then the exact same behavior is called, forcing the user to re-login only if they've closed that browser instance. Is there someway to expire cookies on page leave, or is this the smartass thing you were referring to? :) -- Ryan Parr - Original Message - From: Jon Robison [EMAIL PROTECTED] To: Ron Beck [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 12:28 PM Subject: Re: Question... Cookies! /me is in smartass mode today. --Jon Ron Beck wrote: Hello all, I need to know how to clear the $ENV variables. For example, I use a .htaccess file for specific directories which requires the user to enter userID and password. When they exit the page, I want them to have to re-enter userID and passwd if they enter the page again. Does anyone know how this is accomplished? TIA, Ron
Custom Logging and User Tracking
I'm trying to setup some custom logging including the whole User/Session tracking thing. The problem that I'm encountering is how to log for the page that was requested and ignore all the additional files that may be included in the page. I.e. graphics. Without trying to maintain session uniqueness by comparing mod_uniqueid values. return DECLINED unless($r-is_main()); does nothing return DECLINED unless($r-is_initial_req()); does nothing PerlFixupHandler logs every included file (is this what a subrequest is?) PerlLogHandler logs every included file PerlHandler only logs the initial request, but only logs for the / URI request. No other URI'sare logged. my $code = EO_CODE_SAMPLE; sub handler {my $r = shift; open TRACK, "/usr/local/www/usertracker.txt" or die "Couldn't open log: $!";print TRACK join("\t",($r-hostname,$r-uri,scalar(localtime),$r-connection-remote_ip,$r-connection-hostname || '-' ,$r-header_in('Referer') || '-',$r-header_in('User-agent'))),"\n";close TRACK;return DECLINED;} EO_CODE_SAMPLE
Re: Custom Logging and User Tracking
Unfortunately we do have areas on the site where a link would point directly to a graphic file, which I'd like to log. Otherwise that would work quite well. I had always thought that these extra requests would be subrequests. If not, though, what would be the definition of a sub-request? -- Ryan - Original Message - From: Ask Bjoern Hansen [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, February 13, 2002 12:02 PM Subject: Re: Custom Logging and User Tracking On Wed, 13 Feb 2002, Ryan Parr wrote: I'm trying to setup some custom logging including the whole User/Session tracking thing. The problem that I'm encountering is how to log for the page that was requested and ignore all the additional files that may be included in the page. I.e. graphics. return DECLINED if $r-content_type =~ m!^image/!; ? - ask -- ask bjoern hansen, http://ask.netcetera.dk/ !try; do(); more than a billion impressions per week, http://valueclick.com
Re: Custom Logging and User Tracking
Nothing special to the way these sites work. You can check out http://www.rileyjames.com and http://www.ryanparr.com (the programming on the latter will leave you in awe :) I want to host my sites and have a decent usage statistics location, but I just can't seem to get the logging part down. I've got a long road ahead of me :) For instance, the code below logs the following on entrance to rileyjames.com (setup as PerlFixupHandler): www.rileyjames.com / Wed Feb 13 16:17:15 2002 www.rileyjames.com /index.html Wed Feb 13 16:17:15 2002 www.rileyjames.com /topnavigation.htm Wed Feb 13 16:17:15 2002 www.rileyjames.com /white.htm Wed Feb 13 16:17:15 2002 www.rileyjames.com /green.htm Wed Feb 13 16:17:15 2002 www.rileyjames.com /index1.htm Wed Feb 13 16:17:15 2002 www.rileyjames.com /topnav.css Wed Feb 13 16:17:15 2002 www.rileyjames.com /graphics/redarrow.gif Wed Feb 13 16:17:15 2002 www.rileyjames.com /border.css Wed Feb 13 16:17:15 2002 www.rileyjames.com /text.css Wed Feb 13 16:17:15 2002 www.rileyjames.com /graphics/frontpaglogo.gif Wed Feb 13 16:17:15 2002 The code follows: sub handler { my $r = shift; return DECLINED unless($r-is_main()); # Same behavior when: # return DECLINED unless($r-is_initial_req()); open TRACK, /usr/local/www/usertracker.txt or die Couldn't open log: $!; print TRACK join(\t,($r-hostname,$r-uri,scalar(localtime))),\n; close TRACK; return DECLINED; } -- Ryan - Original Message - From: Ask Bjoern Hansen [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, February 13, 2002 2:34 PM Subject: Re: Custom Logging and User Tracking On Wed, 13 Feb 2002, Ryan Parr wrote: Unfortunately we do have areas on the site where a link would point directly to a graphic file, which I'd like to log. Otherwise that would work quite well. I had always thought that these extra requests would be subrequests. If not, though, what would be the definition of a sub-request? A subrequest is when during processing of the original request make a new internal request. What you are looking for might be the Referer header; but without knowing more exactly how your site works and what URLs you use, it's hard to tell. - ask -- ask bjoern hansen, http://ask.netcetera.dk/ !try; do(); more than a billion impressions per week, http://valueclick.com
Re: Custom Logging and User Tracking
All good points. This code is only to test mod_perl Perl*Handler mechanisms to ensure that I can get the proper log. Once I figure out the necessary routines to do this then I'll integrate it with the rest of my mod, which logs request and session info to a database. -- Ryan - Original Message - From: Dave Rolsky [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: mod_perl list [EMAIL PROTECTED] Sent: Wednesday, February 13, 2002 4:23 PM Subject: Re: Custom Logging and User Tracking On Wed, 13 Feb 2002, Ryan Parr wrote: The code follows: sub handler { my $r = shift; return DECLINED unless($r-is_main()); # Same behavior when: # return DECLINED unless($r-is_initial_req()); open TRACK, /usr/local/www/usertracker.txt or die Couldn't open log: $!; print TRACK join(\t,($r-hostname,$r-uri,scalar(localtime))),\n; close TRACK; return DECLINED; } Hmm, no file locking for something being used by multiple processes? Could be problematic. Is print atomic? Better be sure. Also, if you just open the filehandle once (not in the handler) this'd probably be a bit quicker. And for increased perceived speed have the writing occur in a cleanup handler. -dave /*== www.urth.org we await the New Sun ==*/
Re: Custom Logging and User Tracking
I checked it out and it's a good mod. I've already got the ability to log the data however. The issue that I'm having is that I can't seem to only get 1 log per hit. I can't seem to get around the fact that wherever I put my mod (PerlFixupHandler,PerlHandler,PerlLogHandler) or whatever statement I use ($r-is_main(), $r-is_initial_req()) I'm getting not only the requested page but every other request from the inital request. For instance, I'm getting and logging every graphic, css, javascript, or any other file that's linked in. But for my user tracking I want *just* the initial request, not that and all subrequests. I just can't seem to figure out how to do that. $r-is_main() and $r-is_initial_req() return true for everything. KeepAlive is on. This happens with MSIE, Netscape, Lynx, Opera I would assume Konquerer too. I know that I have to be missing something pretty basic, I'm new to programming in mod_perl. -- Ryan - Original Message - From: Andrew Moore [EMAIL PROTECTED] To: Ryan Parr [EMAIL PROTECTED] Cc: mod_perl list [EMAIL PROTECTED] Sent: Wednesday, February 13, 2002 5:00 PM Subject: Re: Custom Logging and User Tracking On Wed, Feb 13, 2002 at 04:42:02PM -0800, Ryan Parr wrote: All good points. This code is only to test mod_perl Perl*Handler mechanisms to ensure that I can get the proper log. Once I figure out the necessary routines to do this then I'll integrate it with the rest of my mod, which logs request and session info to a database. -- Ryan You might check out Ask's Apache::DBILogger module. It's pretty simple source, so you can make it log whatever you like pretty easily. -Andy