#!perl instead of #!/usr/bin/perl on a Unix/Apache webserver

Discussion in 'Perl Misc' started by joe, Nov 13, 2003.

  1. joe

    joe Guest

    Hi there!

    Can anyone help me out here. I run my CGI-scripts locally on a Windows
    machine. In the shebang line I put #!c:\www\Perl.exe, but it's also possible
    to use only #!perl. On my virtual webserver at my ISP's Unix machine I have
    to use #!/usr/bin/perl.

    The problem is that everytime I upload a script, I have to change the
    shebang line from Windows-mode to Unix-mode.

    Since the #!perl version sounds pretty universal, I was wondering whether it
    is possible to make some sort of link: when 'perl' is requested, Apache
    redirects to #!/usr/bin/perl. Or something else to accomplish the same
    effect. My ISP doesn't know how to do this, without having to move the
    Perl-module completely.

    I'd be very gratefull if anyone could help me out!

    Tia,

    Joe
     
    joe, Nov 13, 2003
    #1
    1. Advertising

  2. On Thu, 13 Nov 2003 11:54:46 GMT
    "joe" <> wrote:

    > Hi there!
    >
    > Can anyone help me out here. I run my CGI-scripts locally on a
    > Windows machine. In the shebang line I put #!c:\www\Perl.exe, but
    > it's also possible to use only #!perl. On my virtual webserver at my
    > ISP's Unix machine I have to use #!/usr/bin/perl.
    >
    > The problem is that everytime I upload a script, I have to change
    > the shebang line from Windows-mode to Unix-mode.
    >
    > Since the #!perl version sounds pretty universal, I was wondering
    > whether it is possible to make some sort of link: when 'perl' is
    > requested, Apache redirects to #!/usr/bin/perl. Or something else to
    > accomplish the same effect. My ISP doesn't know how to do this,
    > without having to move the Perl-module completely.
    >
    > I'd be very gratefull if anyone could help me out!


    One work-around *might* be to put the *NIX shebang in the script and
    executing on Windows by simply putting 'perl' in front of the script
    (like "c:\perl\bin\perl.exe script.pl"). This won't work too well
    through the web server running on Windows, but it *should* work at the
    command line.

    Or, you could create a link on the Windows PC. Make the directory
    structure 'c:\usr\bin' and place the link there pointing to where Perl
    really is on your system. Perl will understand, AFAIK. The '\' can
    be '/' on a Windows system in Perl - FWIU.

    OTOH, I could be wrong about this and hope someone would correct me if
    I am.

    --
    Jim

    Copyright notice: all code written by the author in this post is
    released under the GPL. http://www.gnu.org/licenses/gpl.txt
    for more information.

    a fortune quote ...
    Authors (and perhaps columnists) eventually rise to the top of
    whatever depths they were once able to plumb. -- Stanley
    Kaufman
     
    James Willmore, Nov 13, 2003
    #2
    1. Advertising

  3. joe wrote:
    >
    > Hi there!
    >
    > Can anyone help me out here. I run my CGI-scripts locally on a Windows
    > machine. In the shebang line I put #!c:\www\Perl.exe, but it's also possible
    > to use only #!perl. On my virtual webserver at my ISP's Unix machine I have
    > to use #!/usr/bin/perl.


    AFAIK it is irrelevant _what_ command you put into the shebang line on a
    windows system. Windows doesn't know shebang lines (it maybe knows a .pl
    extension, though), but the perl interpreter knows how to extract
    options (e.g. -w) from the shebang line.

    So, you might be able to put the Linux/UN*X command into the shebang
    line on a Windows system an that would work.

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
     
    Josef Möllers, Nov 13, 2003
    #3
  4. joe

    joe Guest

    Thanks for your input. Because of James' post I realised that I could
    install Perl at the exact same address as on my ISP's webserver. I didn't
    realise that #!c:\usr\bin\perl.exe is interpreted the same as
    #!/usr/bin/perl on a Windows machine. Fortunately it is!

    Thanks again!

    Joe
     
    joe, Nov 13, 2003
    #4
  5. joe

    Bob X Guest

    "Josef Möllers" <> wrote in message
    news:...
    joe wrote:
    >
    > Hi there!
    >
    > Can anyone help me out here. I run my CGI-scripts locally on a Windows
    > machine. In the shebang line I put #!c:\www\Perl.exe, but it's also

    possible
    > to use only #!perl. On my virtual webserver at my ISP's Unix machine I

    have
    > to use #!/usr/bin/perl.


    >AFAIK it is irrelevant _what_ command you put into the shebang line on a
    >windows system. Windows doesn't know shebang lines (it maybe knows a .pl
    >extension, though), but the perl interpreter knows how to extract
    >options (e.g. -w) from the shebang line.


    Actually if you are going to doing web work on Windows then the #!perl is
    necessary.
     
    Bob X, Nov 14, 2003
    #5
  6. joe

    Sam Holden Guest

    On Fri, 14 Nov 2003 02:39:54 GMT, Bob X <> wrote:
    >
    > "Josef Möllers" <> wrote in message
    > news:...
    > joe wrote:
    >>
    >> Hi there!
    >>
    >> Can anyone help me out here. I run my CGI-scripts locally on a Windows
    >> machine. In the shebang line I put #!c:\www\Perl.exe, but it's also

    > possible
    >> to use only #!perl. On my virtual webserver at my ISP's Unix machine I

    > have
    >> to use #!/usr/bin/perl.

    >
    >>AFAIK it is irrelevant _what_ command you put into the shebang line on a
    >>windows system. Windows doesn't know shebang lines (it maybe knows a .pl
    >>extension, though), but the perl interpreter knows how to extract
    >>options (e.g. -w) from the shebang line.

    >
    > Actually if you are going to doing web work on Windows then the #!perl is
    > necessary.


    No it isn't. Some web servers may require that, but that's the web server
    not windows.

    --
    Sam Holden
     
    Sam Holden, Nov 14, 2003
    #6
  7. Sam Holden <> wrote:
    : On Fri, 14 Nov 2003 02:39:54 GMT, Bob X <> wrote:
    :> "Josef Mollers" <> wrote in message
    :> news:...
    :> joe wrote:
    :>>
    :>> Can anyone help me out here. I run my CGI-scripts locally on a Windows
    :>> machine. In the shebang line I put #!c:\www\Perl.exe, but it's also
    :> possible
    :>> to use only #!perl. On my virtual webserver at my ISP's Unix machine I
    :> have
    :>> to use #!/usr/bin/perl.
    :>
    :>>AFAIK it is irrelevant _what_ command you put into the shebang line on a
    :>>windows system. Windows doesn't know shebang lines (it maybe knows a .pl
    :>>extension, though), but the perl interpreter knows how to extract
    :>>options (e.g. -w) from the shebang line.
    :>
    :> Actually if you are going to doing web work on Windows then the #!perl is
    :> necessary.

    : No it isn't. Some web servers may require that, but that's the web server
    : not windows.

    And, sometimes it varies even within the same web server.

    Apache for Windows, for instance, has a way to associate Perl with AS Perl
    that doesn't depend on #! pointing anywhere in particular. But, if you
    use FastCGI, the #! must be correct.

    IIS uses a static mapping of program or ISAPI DLL to extension, so .pl
    and .plx are always handled by ActiveState Perl.

    Note that Apache's mapping of .pl files and IIS's mapping of .pl files
    are entirely different. IIS uses it's own configuration via the IIS MMC,
    and Apache uses a registry entry. Or maybe a different registry entry,
    depending on your configuration.

    Isn't CGI fun?
    --
    Louis Erickson - - http://www.rdwarf.com/~wwonko/

    If you're not part of the solution, you're part of the precipitate.
     
    Louis Erickson, Nov 14, 2003
    #7
  8. joe

    Bob X Guest

    "Louis Erickson" <> wrote in message
    news:bp1keo$kbb$...
    > Sam Holden <> wrote:
    > : On Fri, 14 Nov 2003 02:39:54 GMT, Bob X <> wrote:
    > :> "Josef Mollers" <> wrote in message
    > :> news:...
    > :> joe wrote:
    > :>>
    > :>> Can anyone help me out here. I run my CGI-scripts locally on a Windows
    > :>> machine. In the shebang line I put #!c:\www\Perl.exe, but it's also
    > :> possible
    > :>> to use only #!perl. On my virtual webserver at my ISP's Unix machine I
    > :> have
    > :>> to use #!/usr/bin/perl.
    > :>
    > :>>AFAIK it is irrelevant _what_ command you put into the shebang line on

    a
    > :>>windows system. Windows doesn't know shebang lines (it maybe knows a

    ..pl
    > :>>extension, though), but the perl interpreter knows how to extract
    > :>>options (e.g. -w) from the shebang line.
    > :>
    > :> Actually if you are going to doing web work on Windows then the #!perl

    is
    > :> necessary.
    >
    > : No it isn't. Some web servers may require that, but that's the web

    server
    > : not windows.
    >
    > And, sometimes it varies even within the same web server.
    >
    > Apache for Windows, for instance, has a way to associate Perl with AS Perl
    > that doesn't depend on #! pointing anywhere in particular. But, if you
    > use FastCGI, the #! must be correct.
    >
    > IIS uses a static mapping of program or ISAPI DLL to extension, so .pl
    > and .plx are always handled by ActiveState Perl.
    >
    > Note that Apache's mapping of .pl files and IIS's mapping of .pl files
    > are entirely different. IIS uses it's own configuration via the IIS MMC,
    > and Apache uses a registry entry. Or maybe a different registry entry,
    > depending on your configuration.
    >
    > Isn't CGI fun?
    > --
    > Louis Erickson - - http://www.rdwarf.com/~wwonko/
    >
    > If you're not part of the solution, you're part of the precipitate.

    I am using Apache on Windows and I have to use the #!perl shebang. Then
    again I may not have Apache setup right.

    Didn't mean to imply that anything was wrong with the OS though (per a
    previous poster).
     
    Bob X, Nov 14, 2003
    #8
  9. Bob X wrote:
    > "Louis Erickson" <> wrote in message
    > news:bp1keo$kbb$...
    >
    >>Sam Holden <> wrote:
    >>: On Fri, 14 Nov 2003 02:39:54 GMT, Bob X <> wrote:
    >>:> "Josef Mollers" <> wrote in message
    >>:> news:...
    >>:> joe wrote:
    >>:>>
    >>:>> Can anyone help me out here. I run my CGI-scripts locally on a Windows
    >>:>> machine. In the shebang line I put #!c:\www\Perl.exe, but it's also
    >>:>> possible
    >>:>> to use only #!perl. On my virtual webserver at my ISP's Unix machine I
    >>:>> have
    >>:>> to use #!/usr/bin/perl.
    >>:>
    >>:>>AFAIK it is irrelevant _what_ command you put into the shebang line on

    > a
    >>:>>windows system. Windows doesn't know shebang lines (it maybe knows a

    > .pl
    >>:>>extension, though), but the perl interpreter knows how to extract
    >>:>>options (e.g. -w) from the shebang line.
    >>:>


    [snip]

    > I am using Apache on Windows and I have to use the #!perl shebang. Then
    > again I may not have Apache setup right.
    >
    > Didn't mean to imply that anything was wrong with the OS though (per a
    > previous poster).


    I'm using apache too (on my win32 machine for testing), and have this
    line in my httpd.conf:

    ScriptInterpreterSource Registry

    This way apache doesn't need a perfectly written #! line, since it looks
    up the association in the windows registry.
    The upside of this is that you can put the #! line as needed by your
    real web server, and still have a working script in your test environment.
    The downside of this is that you have to put every extension you use in
    the registry (.cgi isn't by default associated with perl.exe).
    In both cases the perl interpreter honors the switches in the shebang
    line, so that's nice.

    Matthias
     
    Matthias Weckman, Nov 14, 2003
    #9
    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. John Salerno
    Replies:
    30
    Views:
    1,980
    Stephan Kuhagen
    Aug 10, 2006
  2. Yves Dorfsman

    #!/usr/bin/env python vs. #!/usr/bin/python

    Yves Dorfsman, May 2, 2008, in forum: Python
    Replies:
    27
    Views:
    2,021
    Tim Roberts
    May 10, 2008
  3. anne001
    Replies:
    1
    Views:
    498
  4. Mark Richards
    Replies:
    6
    Views:
    266
    A. Sinan Unur
    Nov 18, 2007
  5. Gilles
    Replies:
    7
    Views:
    563
    Matej Cepl
    Sep 30, 2012
Loading...

Share This Page