Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   HOW to rename a NPH script ? (http://www.velocityreviews.com/forums/t899509-how-to-rename-a-nph-script.html)

Ulrich Mueller 08-16-2006 04:58 PM

HOW to rename a NPH script ?
 

Hallo,

I've a NPH perl CGI under apache

let's say `nph-test.cgi`:
#!/usr/bin/perl
print "HTTP/1.1 200 OK\nContent-Type: text/html\n\nHALLO\n";
print "we're ".(exists $ENV{MOD_PERL}?"":"NOT ")."under mod_perl";
1;

and want to rename it to `hallo`
without `nph-` prefix.

What possibilities I have to tell apache,
that this is still an nph script,
either with mod_perl or not,
via (preferably) changing code itself or local .htaccess
(so ScriptAlias doesn't work),

I tried a lot, $|=1, symbolic links, or

SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlSendHeader Off
PerlOptions -ParseHeaders
Options +ExecCGI

or

RewriteEngine On
RewriteBase /cgi-bin
RewriteRule ^hallo$ nph-test.cgi

or searching the web, no succeeding until now :(

Thanks for your help,
Ulrich



Matt Garrish 08-16-2006 09:37 PM

Re: HOW to rename a NPH script ?
 

Ulrich Mueller wrote:

> Hallo,
>
> I've a NPH perl CGI under apache


>
> What possibilities I have to tell apache,
> that this is still an nph script,


Just a piece of advice, although your question makes passing reference
to perl, it's really an apache configuration issue. You're much more
likely to get the advice you're looking for in an apache group. You
might hit on someone who knows here, but you're equally likely to hit
on someone who only half knows, and there'd be no one to tell you what
they missed.

Matt


Ulrich Mueller 08-17-2006 07:58 AM

Re: HOW to rename a NPH script ?
 
On Wed, 16 Aug 2006, Matt Garrish wrote:

>
> Ulrich Mueller wrote:
>
> > Hallo,
> >
> > I've a NPH perl CGI under apache

>
> >
> > What possibilities I have to tell apache,
> > that this is still an nph script,

>
> Just a piece of advice, although your question makes passing reference
> to perl, it's really an apache configuration issue. You're much more
> likely to get the advice you're looking for in an apache group. You
> might hit on someone who knows here, but you're equally likely to hit
> on someone who only half knows, and there'd be no one to tell you what
> they missed.
>
> Matt
>


Thanks for the advice though it was not what I was looking for.
http://perl.apache.org/start/index.html
states that "mod_perl is the marriage of Apache and Perl",
so I asked the mother first via alt.apache.configuration.
No answer for two days, so I tried asking the father,
And got "ask the mother!"
Child seems not to be grown up old enough
to participate in usenet, is it?
So it seems, I have to try to figure it out myself,
and tell the result both of them...

Inserting "ScriptAlias /hallo /path/to/nph-script/nph-test.cgi"
into httpd.conf is an easy solution if you are allowed to.
Otherwise maybe Apache::Fake, but haven't tried this yet.
Or maybe very simple... ideas are still welcome,
Ulrich



Matt Garrish 08-17-2006 10:56 AM

Re: HOW to rename a NPH script ?
 

Ulrich Mueller wrote:

> On Wed, 16 Aug 2006, Matt Garrish wrote:
>
> >
> > Ulrich Mueller wrote:
> >
> > > Hallo,
> > >
> > > I've a NPH perl CGI under apache

> >
> > >
> > > What possibilities I have to tell apache,
> > > that this is still an nph script,

> >
> > Just a piece of advice, although your question makes passing reference
> > to perl, it's really an apache configuration issue. You're much more
> > likely to get the advice you're looking for in an apache group. You
> > might hit on someone who knows here, but you're equally likely to hit
> > on someone who only half knows, and there'd be no one to tell you what
> > they missed.
> >
> > Matt
> >

>
> Thanks for the advice though it was not what I was looking for.
> http://perl.apache.org/start/index.html
> states that "mod_perl is the marriage of Apache and Perl",
> so I asked the mother first via alt.apache.configuration.
> No answer for two days, so I tried asking the father,
> And got "ask the mother!"
> Child seems not to be grown up old enough
> to participate in usenet, is it?
> So it seems, I have to try to figure it out myself,
> and tell the result both of them...
>
> Inserting "ScriptAlias /hallo /path/to/nph-script/nph-test.cgi"
> into httpd.conf is an easy solution if you are allowed to.
> Otherwise maybe Apache::Fake, but haven't tried this yet.
> Or maybe very simple... ideas are still welcome,


You didn't quite get the "no one cares about apache configuration here"
part. This is a group to discuss Perl coding problems, and your
question has nothing to do about Perl and everything to do about apache
and configuring nph scripts. If you want to post off-topic questions
don't get all huffy when no one responds. You'd be better off to follow
up in the apache group as that's where most people would look for this
kind of answer.

Matt


Ulrich Mueller 08-18-2006 01:00 AM

Re: HOW to rename a NPH script ?
 
On Thu, 17 Aug 2006, Matt Garrish wrote:

>
> Ulrich Mueller wrote:
>
> > On Wed, 16 Aug 2006, Matt Garrish wrote:
> >
> > >
> > > Ulrich Mueller wrote:
> > >
> > > > Hallo,
> > > >
> > > > I've a NPH perl CGI under apache
> > >
> > > >
> > > > What possibilities I have to tell apache,
> > > > that this is still an nph script,
> > >
> > > Just a piece of advice, although your question makes passing reference
> > > to perl, it's really an apache configuration issue. You're much more
> > > likely to get the advice you're looking for in an apache group. You
> > > might hit on someone who knows here, but you're equally likely to hit
> > > on someone who only half knows, and there'd be no one to tell you what
> > > they missed.
> > >
> > > Matt
> > >

> >
> > Thanks for the advice though it was not what I was looking for.
> > http://perl.apache.org/start/index.html
> > states that "mod_perl is the marriage of Apache and Perl",
> > so I asked the mother first via alt.apache.configuration.
> > No answer for two days, so I tried asking the father,
> > And got "ask the mother!"
> > Child seems not to be grown up old enough
> > to participate in usenet, is it?
> > So it seems, I have to try to figure it out myself,
> > and tell the result both of them...
> >
> > Inserting "ScriptAlias /hallo /path/to/nph-script/nph-test.cgi"
> > into httpd.conf is an easy solution if you are allowed to.
> > Otherwise maybe Apache::Fake, but haven't tried this yet.
> > Or maybe very simple... ideas are still welcome,

>
> You didn't quite get the "no one cares about apache configuration here"
> part. This is a group to discuss Perl coding problems, and your
> question has nothing to do about Perl and everything to do about apache
> and configuring nph scripts. If you want to post off-topic questions
> don't get all huffy when no one responds. You'd be better off to follow
> up in the apache group as that's where most people would look for this
> kind of answer.
>
> Matt
>


OFF-TOPIC:
YOUR comments seem to be more Off-topic to me,
you should post them to society.usenet.moderation.strict.
Cause, tell me what is Apache::Fake if it's not perl code.
And I asked for doing this by coding at first, only secondly by .htaccess.
But you seem to have your very strict idea about off-topics
in this group. Well for me as newbie, excuse me,
I didn't know, maybe you should call this group
comp.lang.perl.syntax instead of misc.


ON-TOPIC: (I hope)
Some got it working by using method
assbackwards() of RequestRec somehow as in

sub handler {
my $r = shift;

$r->assbackwards(1);
print "HTTP/1.1 200 OK\n";
print "Content-Type: text/plain\n\n";
print "This is PERL printing!\n";

return Apache::OK;
}

but not for me :(
Ulrich

Ulrich Mueller 08-18-2006 11:05 AM

Re: HOW to rename a NPH script ?
 
On Fri, 18 Aug 2006, A. Sinan Unur wrote:

>
> How about comp.infosystems.www.servers.unix ?


thanks, I will try to get an answer there too.


>
> You asked:
>
> >> > > > I've a NPH perl CGI under apache
> >> > > >
> >> > > > What possibilities I have to tell apache,
> >> > > > that this is still an nph script,

>
> If that is not an Apache configuration question, and thus off-topic, I
> do not know what would be.



hey men, you're starting making me angry. I asked:

> What possibilities I have to tell apache,
> that this is still an nph script,
> either with mod_perl or not,
> via (preferably) changing code itself or local .htaccess

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

so please leave it in context,
I want the PERL script to tell apache,
I asked for some lines of PERL CODE, preferably,
sorry, if you misunderstood, English is not my mothertongue,

and I told you, that I HAVE ASKED some apache group before,
at least they were not throwing me out,
by complaining that this is a question concerning perl,

> I won't be seeing your messages. Bye.
>
> Sinan
>


Be happy.
Ulrich

Sherm Pendley 08-18-2006 11:32 AM

Re: HOW to rename a NPH script ?
 
Ulrich Mueller <umu@hrz.tu-chemnitz.de> writes:

> hey men, you're starting making me angry. I asked:
>
>> What possibilities I have to tell apache,
>> that this is still an nph script,
>> either with mod_perl or not,
>> via (preferably) changing code itself or local .htaccess

> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> so please leave it in context,
> I want the PERL script to tell apache,
> I asked for some lines of PERL CODE, preferably,
> sorry, if you misunderstood, English is not my mothertongue,


Sorry, but *you* have misunderstood. We get the question just fine. The
answer is no, you cannot do that from inside the Perl script. The Apache
server must be configured - either in .htaccess or in httpd.conf - to
process your script as NPH.

From the CGI.pm documentation:

"Servers use a variety of conventions for designating CGI scripts as NPH.
Many Unix servers look at the beginning of the script's name for the
prefix "nph-". The Macintosh WebSTAR server and Microsoft's Internet
Information Server, in contrast, try to decide whether a program is an
NPH script by examining the first line of script output."

Apache is not one of those servers that examine the script's output - it
uses the nph- prefix.

You could use mod_rewrite to add the nph- prefix to requests within a given
directory. You'd still need to keep the prefix on your files, but at least
it wouldn't be visible to users.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Ulrich Mueller 08-18-2006 12:43 PM

Re: HOW to rename a NPH script ?
 
On Fri, 18 Aug 2006, Sherm Pendley wrote:

> Ulrich Mueller <umu@hrz.tu-chemnitz.de> writes:
>
> > so please leave it in context,
> > I want the PERL script to tell apache,
> > I asked for some lines of PERL CODE, preferably,
> > sorry, if you misunderstood, English is not my mothertongue,

>
> Sorry, but *you* have misunderstood. We get the question just fine. The
> answer is no, you cannot do that from inside the Perl script. The Apache


Hallo Sherm,
thanks for your reply, meanwhile I ve read
http://augustmail.com/~tadmc/clpmisc...uidelines.html
and I didn't want to disturb your group, promised,
and in case the answer is *NO*, then that question doesn't belong here,
but how should me unexperienced programmer know before,
(finding things like $|=1 and assbackwards() by web searches)
so I thought I ve the right to ask,
now you are the first one who is saying *NO*,
and I thank you for.

> You could use mod_rewrite to add the nph- prefix to requests within a given
> directory. You'd still need to keep the prefix on your files, but at least
> it wouldn't be visible to users.
>

I've tried this before, but when user asked for http://.../hallo,
nph-test.cgi was correctly executed as nph, but then in the browser
there was written http://.../nph-test.cgi as well. So is there a way
the hallo is rewritten internally, but not for the user's browser.
Sorry Sherm, I know, that this is apache stuff now...
so feel free, to ignore this attached final question,
without blaming me, please, thanks again.
Ulrich

Sherm Pendley 08-18-2006 02:21 PM

Re: HOW to rename a NPH script ?
 
Ulrich Mueller <umu@hrz.tu-chemnitz.de> writes:

> On Fri, 18 Aug 2006, Sherm Pendley wrote:
>
>> You could use mod_rewrite to add the nph- prefix to requests within a given
>> directory. You'd still need to keep the prefix on your files, but at least
>> it wouldn't be visible to users.
>>

> I've tried this before, but when user asked for http://.../hallo,
> nph-test.cgi was correctly executed as nph, but then in the browser
> there was written http://.../nph-test.cgi as well. So is there a way
> the hallo is rewritten internally, but not for the user's browser.


It might be worth investigating the Alias and/or AliasMatch directives - they
can (re)define the mapping from URL to filenames.

Whether the prefix of the file name or the URL is used to determine whether
to run the script as NPH is the obvious question, of course - but I'm afraid
I don't know the answer offhand. Sorry. You'll probably be able to get an
answer to that one in an Apache group.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Matt Garrish 08-18-2006 06:29 PM

Re: HOW to rename a NPH script ?
 

Ulrich Mueller wrote:

> On Fri, 18 Aug 2006, Sherm Pendley wrote:
>
> > Ulrich Mueller <umu@hrz.tu-chemnitz.de> writes:
> >
> > > so please leave it in context,
> > > I want the PERL script to tell apache,
> > > I asked for some lines of PERL CODE, preferably,
> > > sorry, if you misunderstood, English is not my mothertongue,

> >
> > Sorry, but *you* have misunderstood. We get the question just fine. The
> > answer is no, you cannot do that from inside the Perl script. The Apache

>
> Hallo Sherm,
> thanks for your reply, meanwhile I ve read
> http://augustmail.com/~tadmc/clpmisc...uidelines.html
> and I didn't want to disturb your group, promised,
> and in case the answer is *NO*, then that question doesn't belong here,
> but how should me unexperienced programmer know before,


Give me a break! I told you at the start that though your question
makes passing reference to Perl it is an Apache configuration issue and
you'd be better off posting somewhere else. For someone who demands
context I'm surprised how quickly you conveniently forgot that part.

This isn't your personal help desk, and the more you whine and cry like
a baby (as you've done throughout this thread), the less likely you'll
be to find anyone to help you in the future.

Matt



All times are GMT. The time now is 09:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57