HOW to rename a NPH script ?

Discussion in 'Perl Misc' started by Ulrich Mueller, Aug 16, 2006.

  1. 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
    Ulrich Mueller, Aug 16, 2006
    #1
    1. Advertising

  2. Ulrich Mueller

    Matt Garrish Guest

    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
    Matt Garrish, Aug 16, 2006
    #2
    1. Advertising

  3. 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
    Ulrich Mueller, Aug 17, 2006
    #3
  4. Ulrich Mueller

    Matt Garrish Guest

    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
    Matt Garrish, Aug 17, 2006
    #4
  5. 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, Aug 18, 2006
    #5
  6. 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
    Ulrich Mueller, Aug 18, 2006
    #6
  7. Ulrich Mueller <-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
    Sherm Pendley, Aug 18, 2006
    #7
  8. On Fri, 18 Aug 2006, Sherm Pendley wrote:

    > Ulrich Mueller <-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/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
    Ulrich Mueller, Aug 18, 2006
    #8
  9. Ulrich Mueller <-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
    Sherm Pendley, Aug 18, 2006
    #9
  10. Ulrich Mueller

    Matt Garrish Guest

    Ulrich Mueller wrote:

    > On Fri, 18 Aug 2006, Sherm Pendley wrote:
    >
    > > Ulrich Mueller <-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/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
    Matt Garrish, Aug 18, 2006
    #10
  11. 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
    Ulrich Mueller, Aug 19, 2006
    #11
  12. Ulrich Mueller

    -berlin.de Guest

    Ulrich Mueller <-chemnitz.de> wrote in comp.lang.perl.misc:
    >
    >
    > 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
    -berlin.de, Aug 21, 2006
    #12
  13. On Mon, 21 Aug 2006, -berlin.de wrote:

    > 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...
    Ulrich Mueller, Aug 22, 2006
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rajat
    Replies:
    3
    Views:
    677
    Jorgen Grahn
    Jan 8, 2010
  2. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    539
    Jan Kaliszewski
    Jan 7, 2010
  3. Gilles Ganault
    Replies:
    2
    Views:
    250
    Gilles Ganault
    Apr 8, 2011
  4. Chris Morris

    cgi bug? with iis 5 and nph

    Chris Morris, Sep 3, 2003, in forum: Ruby
    Replies:
    0
    Views:
    132
    Chris Morris
    Sep 3, 2003
  5. kwalike57
    Replies:
    6
    Views:
    219
    Tad J McClellan
    Jan 10, 2008
Loading...

Share This Page