mixing cgi-bin mod_perl

2001-12-20 Thread Miroslav Madzarevic

The scenario:
There are two folders
/cgi-binwith plain perl cgi
/mod-perl   with Apache::Registry scripts

The application is being moved from cgi to mod_perl (Apache::Registry) one
script at a time.
My friend has a strange idea.
He wants to mix cgi-bin  mod_perl by testing all of the scripts in
cgi-bin and putting one cgi-script at a time into mod-perl folder.
He wants to do this internaly in Apache, changing the request for
a particular script so for example when you reference /cgi-bin/some_scr.pl
you actually end with /mod-perl/some_scr.pl. He doesn't want to
change the a href code from html files to stop pointing at /cgi-bin.
By moving all of them one at a time all of the application will
eventually end up working under mod_perl.

How can he do that ?

He thought of using mod_proxy or mod_rewrite.
The scripts are badly written and have been developed for three years
so far by various perl programmers.





Re: mixing cgi-bin mod_perl

2001-12-20 Thread Thomas Eibner

On Thu, Dec 20, 2001 at 09:41:31PM +0100, Miroslav Madzarevic wrote:
 The scenario:
 There are two folders
 /cgi-binwith plain perl cgi
 /mod-perl   with Apache::Registry scripts
 
 The application is being moved from cgi to mod_perl (Apache::Registry) one
 script at a time.
 My friend has a strange idea.
 He wants to mix cgi-bin  mod_perl by testing all of the scripts in
 cgi-bin and putting one cgi-script at a time into mod-perl folder.
 He wants to do this internaly in Apache, changing the request for
 a particular script so for example when you reference /cgi-bin/some_scr.pl
 you actually end with /mod-perl/some_scr.pl. He doesn't want to
 change the a href code from html files to stop pointing at /cgi-bin.
 By moving all of them one at a time all of the application will
 eventually end up working under mod_perl.
 
 How can he do that ?

When he's still renaming the files he could do something like:
Alias /cgi-bin/script1.pl /mod-perl/script1.pl

And when he has moved them all just move the directory so it works from
the original directory. 

-- 
  Thomas Eibner http://thomas.eibner.dk/ DnsZone http://dnszone.org/
  mod_pointer http://stderr.net/mod_pointer 



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Perrin Harkins

 He wants to mix cgi-bin  mod_perl by testing all of the scripts in
 cgi-bin and putting one cgi-script at a time into mod-perl folder.

A very simple way to do this is to use Location directives to add them to
PerlRun one at a time:

Location /cgi-bin/some_scr.pl
SetHandler perl-script
 PerlHandler Apache::PerlRun
 Options +ExecCGI
 #optional
 PerlSendHeader On
...
/Location

Location /cgi-bin/some_other_scr.pl
SetHandler perl-script
PerlHandler Apache::PerlRun
Options +ExecCGI
#optional
PerlSendHeader On
...
/Location

These directives will override the broader directives for /cgi-bin/.

You could use mod_macro (or Perl sections) to avoid all the duplicated
typing.

- Perrin




Re: mixing cgi-bin mod_perl

2001-12-20 Thread Paul Lindner

On Thu, Dec 20, 2001 at 09:41:31PM +0100, Miroslav Madzarevic wrote:
 The scenario:
 There are two folders
 /cgi-binwith plain perl cgi
 /mod-perl   with Apache::Registry scripts
 
 The application is being moved from cgi to mod_perl (Apache::Registry) one
 script at a time.
 My friend has a strange idea.
 He wants to mix cgi-bin  mod_perl by testing all of the scripts in
 cgi-bin and putting one cgi-script at a time into mod-perl folder.
 He wants to do this internaly in Apache, changing the request for
 a particular script so for example when you reference /cgi-bin/some_scr.pl
 you actually end with /mod-perl/some_scr.pl. He doesn't want to
 change the a href code from html files to stop pointing at /cgi-bin.
 By moving all of them one at a time all of the application will
 eventually end up working under mod_perl.
 
 How can he do that ?
 
 He thought of using mod_proxy or mod_rewrite.
 The scripts are badly written and have been developed for three years
 so far by various perl programmers.

I'd use mod_rewrite or, even better, use the power of the
PerlTransHandler..  Activate the following handler by adding

  PerlTransHandler Moo::my_trans_handler

to your httpd.conf.  In your example it will check for

  /usr/local/apache/cgi-bin/some_scr.pl_mod_perl_me

If that file exists we rewrite the URL to use the /mod-perl prefix
internally.


sub Moo::my_trans_handler {
  my $r = shift;
  my $uri = $r-uri;

  return DECLINED unless ($uri =~ s,^/cgi-bin/,,);
  
  if (-f /usr/local/apache/cgi-bin/${uri}_mod_perl_me) {
$uri = = /mod-perl/$uri
$r-uri(/mod-perl/$uri);
  }
  return DECLINED;
}
  

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Luciano Miguel Ferreira Rocha


I would just use:

find . -type f -print0 | xargs -0 perl -spi -e 
's/cgi-bin\/some_scr.pl/mod-perl\/some_scr.pl/g;'

Regards,
Luciano Rocha

-- 
Luciano Rocha, [EMAIL PROTECTED]

The trouble with computers is that they do what you tell them, not what
you want.
-- D. Cohen



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Randal L. Schwartz

 Luciano == Luciano Miguel Ferreira Rocha [EMAIL PROTECTED] writes:

Luciano I would just use:

Luciano find . -type f -print0 | xargs -0 perl -spi -e 
's/cgi-bin\/some_scr.pl/mod-perl\/some_scr.pl/g;'

Ewww.  Why two processes?

use File::Find;
@ARGV = ();
find sub { push @ARGV, $File::Find::name if -f }, .;
$^I = ; # or .bak
while () {
  s/cgi-bin(\/some_scr.pl)/mod-perl$1/g;
  print;
}

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Luciano Miguel Ferreira Rocha

On Thu, Dec 20, 2001 at 03:16:48PM -0800, Randal L. Schwartz wrote:
 Luciano find . -type f -print0 | xargs -0 perl -spi -e 
's/cgi-bin\/some_scr.pl/mod-perl\/some_scr.pl/g;'
 
 Ewww.  Why two processes?

Because I would rather type only a single line to do what a 8 line program
will do. What's the point of using perl if you aren't lazy? And then,
what's the point of using perl if you can be even lazier?

Perl extends the normal Unix Tools, but I won't drop them for perl just
because it's the cool language of the moment... (Not that I don't like
perl, mind you...)

Regards,

Luciano Rocha

-- 
Luciano Rocha, [EMAIL PROTECTED]

The trouble with computers is that they do what you tell them, not what
you want.
-- D. Cohen



Re: mixing cgi-bin mod_perl

2001-12-20 Thread Hans Poo

El Jue 20 Dic 2001 20:46, Luciano Miguel Ferreira Rocha escribió:
 On Thu, Dec 20, 2001 at 03:16:48PM -0800, Randal L. Schwartz wrote:
  Luciano find . -type f -print0 | xargs -0 perl -spi -e
  's/cgi-bin\/some_scr.pl/mod-perl\/some_scr.pl/g;'
 
  Ewww.  Why two processes?

 Because I would rather type only a single line to do what a 8 line program
 will do. What's the point of using perl if you aren't lazy? And then,
 what's the point of using perl if you can be even lazier?

 Perl extends the normal Unix Tools, but I won't drop them for perl just
 because it's the cool language of the moment... (Not that I don't like
 perl, mind you...)

 Regards,

 Luciano Rocha

I think Randall is just trying to show a cool application of File::Find, and 
int the menatime save some CPU and memory cycles.

I like it.

Hans Poo





Re: mixing cgi-bin mod_perl

2001-12-20 Thread Luciano Miguel Ferreira Rocha

On Thu, Dec 20, 2001 at 09:29:26PM -0300, Hans Poo wrote:
 I think Randall is just trying to show a cool application of File::Find, and 
 int the menatime save some CPU and memory cycles.

Sorry, I didn't mean to be or sound harsh...

My apologies to Randall and everybody on this list

Regards,
Luciano Rocha

-- 
Luciano Rocha, [EMAIL PROTECTED]

The trouble with computers is that they do what you tell them, not what
you want.
-- D. Cohen