HOW to rename a NPH script ?


U

Ulrich Mueller

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
 
Ad

Advertisements

M

Matt Garrish

Ulrich said:
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
 
U

Ulrich Mueller

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
 
M

Matt Garrish

Ulrich said:
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
 
U

Ulrich Mueller

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
 
U

Ulrich Mueller

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

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

You asked:


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
 
Ad

Advertisements

S

Sherm Pendley

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

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

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--
 
U

Ulrich Mueller

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/clpmisc_guidelines.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
 
S

Sherm Pendley

Ulrich Mueller said:
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--
 
M

Matt Garrish

Ulrich said:
Hallo Sherm,
thanks for your reply, meanwhile I ve read
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.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
 
U

Ulrich Mueller

let's shortly analyze this communication process:

1. I POSE A QUESTION
2. YOU ADVICE ME TO ASK SOMEWHERE ELSE (STILL KINDLY)
3. I TELL YOU I VE DONE SO ALREADY WITH NO LUCK, SO TRYING HERE (KINDLY)
4. YOU JUST REPEAT 2. WITHOUT ANY CONSIDERATION OF 3.
( maybe I got it wrong, as English is not my mothertongue,
but terms like "you didn't get it" , "get huffy" and "be off"
don't seem to be kindly advice anymore )
5. I'M STARTING OFF-TOPIC AS WELL
( sorry for adopting to this style that quickly )

.... more flames
.... filtering rules
.... i read guidelines
.... Sherm deescalates situation, thanks again
.... I explain and excuse my posting
.... You just GO ON with real insults "whine and cry like a baby ..."

So this thing gets me to the point where I suppose,
that between 3. and 4. you maybe misunderstood
" Child seems not to be grown up old enough
to participate in usenet, is it? "
This didn't refer to you (oooh, what an insult) but to mod_perl,
a child of mother apache and father perl,
and I just asked this way
if there is a newsgroup for mod_perl maybe,
sorry for my tries in poetry... :(

Ulrich
 
Ad

Advertisements

A

anno4000

Ulrich Mueller said:
let's shortly analyze this communication process:

1. I POSE A QUESTION
2. YOU ADVICE ME TO ASK SOMEWHERE ELSE (STILL KINDLY)
3. I TELL YOU I VE DONE SO ALREADY WITH NO LUCK, SO TRYING HERE (KINDLY)
4. YOU JUST REPEAT 2. WITHOUT ANY CONSIDERATION OF 3.

Don't shout!

What's to consider about 3? The fact that you got no replies elsewhere
doesn't make it topical here. When the baker is closed, do you go to the
butcher next door to get your breakfast rolls?

Anno
 
Ad

Advertisements

U

Ulrich Mueller

What's to consider about 3? The fact that you got no replies elsewhere
doesn't make it topical here. When the baker is closed, do you go to the
butcher next door to get your breakfast rolls?

Anno
yes, I wanted a sandwich with bacon,
and usually get it from either the baker or the butcher,
as long as there's no war...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top