Linux and Win32 compatability

Discussion in 'Perl Misc' started by Test Test., Apr 28, 2006.

  1. Test Test.

    Test Test. Guest

    My most humbl apolgies if this is not the right place for this
    posting.

    My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    my Perl Scripts start with the usual line:
    #!"C:\Program Files\Perl\bin\perl.exe"

    But,
    My Web host is Linux based, with both Perl and Apache. So, the top
    line my Perl scripts at my ISP site is: #!/usr/bin/perl --

    So far, this top line is the only line which is different between my
    local Win2K site and the online website.

    This question must have been asked before, but, is there any way of
    making the two scripts compatable so that I don't need to track 2
    versions just becuase of the top line?

    Thanks in anticipation.

    Regards

    Nick
    Test Test., Apr 28, 2006
    #1
    1. Advertising

  2. Test Test.

    Guest

    Test Test. wrote:

    > My most humbl apolgies if this is not the right place for this
    > posting.
    >
    > My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    > my Perl Scripts start with the usual line:
    > #!"C:\Program Files\Perl\bin\perl.exe"
    >


    You shouldn't need the shebang line at all under Windows provided your
    path and the file extension association are set up correctly. I am
    currently working under XP but used Win2000 until September last year
    and this works just fine for me

    # No shebang !!
    use strict;
    use warnings;

    print STDERR "\nHello world\n";

    exit(0);


    I just tried changing the first line so I now have

    #!/usr/local/bin/perl
    use strict;
    use warnings;

    print STDERR "\nHello world\n";

    exit(0);

    and this also runs with no problems.

    As far as I am aware any line starting with a hash will be treated as a
    comment under windoze.
    , Apr 28, 2006
    #2
    1. Advertising

  3. Test Test.

    prawn Guest

    wrote:

    > As far as I am aware any line starting with a hash will be treated as a
    > comment under windoze.


    *Ding*. I always put a unix stylee shebang on my win32 perl scripts. It
    saves loads of grief when porting code.


    --
    p LotR#9 BotM#1
    prawn, Apr 28, 2006
    #3
  4. wrote:
    > Test Test. wrote:
    >
    >
    >>My most humbl apolgies if this is not the right place for this
    >>posting.
    >>
    >>My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    >>my Perl Scripts start with the usual line:
    >>#!"C:\Program Files\Perl\bin\perl.exe"
    >>

    >
    >
    > You shouldn't need the shebang line at all under Windows provided your
    > path and the file extension association are set up correctly. I am
    > currently working under XP but used Win2000 until September last year
    > and this works just fine for me
    >
    > # No shebang !!
    > use strict;
    > use warnings;
    >
    > print STDERR "\nHello world\n";
    >
    > exit(0);
    >
    >
    > I just tried changing the first line so I now have
    >
    > #!/usr/local/bin/perl
    > use strict;
    > use warnings;
    >
    > print STDERR "\nHello world\n";
    >
    > exit(0);
    >
    > and this also runs with no problems.
    >
    > As far as I am aware any line starting with a hash will be treated as a
    > comment under windoze.


    Any line starting with a hash will be treated as a comment in Perl!

    AFAIK the Perl interpreter in Windows does look at the shebang line in
    order to detect command line arguments, e.g. the deprecated '-w' would
    be detected. The command path, however, is ignored.




    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
    Josef Moellers, Apr 28, 2006
    #4
  5. Test Test. <> wrote in news::

    >
    > My most humbl apolgies if this is not the right place for this
    > posting.
    >
    > My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    > my Perl Scripts start with the usual line:
    > #!"C:\Program Files\Perl\bin\perl.exe"
    >
    > But,
    > My Web host is Linux based, with both Perl and Apache. So, the top
    > line my Perl scripts at my ISP site is: #!/usr/bin/perl --
    >
    > So far, this top line is the only line which is different between my
    > local Win2K site and the online website.
    >
    > This question must have been asked before, but, is there any way of
    > making the two scripts compatable so that I don't need to track 2
    > versions just becuase of the top line?


    The other responses to your post fail to take into account the fact that
    Apache on Windows does pay attention to the shebang line.

    To keep the shebang line for the Unix system, but tell Apache on Windows
    not to pay attention to the shebang line, see

    http://httpd.apache.org/docs/2.0/mod/core.html#scriptinterpretersource

    Use

    ScriptInterpreterSource Registry-Strict

    in your httpd.conf file, and add

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI]
    "command"="c:\\opt\\perl\\bin\\perl.exe -T \"%1\""

    to your registry (replace the path to perl.exe with whatever is
    appropriate for your system).

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Apr 28, 2006
    #5
  6. Test Test. wrote:
    > My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    > my Perl Scripts start with the usual line:
    > #!"C:\Program Files\Perl\bin\perl.exe"
    >
    > But, My Web host is Linux based, with both Perl and Apache. So, the
    > top line my Perl scripts at my ISP site is: #!/usr/bin/perl --


    <snip>

    > is there any way of making the two scripts compatable so that I don't
    > need to track 2 versions just becuase of the top line?


    These are two solutions. First the simple:

    http://groups.google.com/group/comp.lang.perl.misc/msg/5d01d5affb0294e8

    and then a more elegant(?):

    http://groups.google.com/group/comp.lang.perl.misc/msg/46026827a583f19d

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Apr 28, 2006
    #6
  7. Test Test.

    Test Test. Guest

    On 28 Apr 2006 02:11:19 -0700, wrote:

    >
    >Test Test. wrote:
    >
    >> My most humbl apolgies if this is not the right place for this
    >> posting.
    >>
    >> My development PC is Win2k with Apache and Perl v5.6.1 for Win32. So,
    >> my Perl Scripts start with the usual line:
    >> #!"C:\Program Files\Perl\bin\perl.exe"
    >>

    >
    >You shouldn't need the shebang line at all under Windows provided your
    >path and the file extension association are set up correctly. I am
    >currently working under XP but used Win2000 until September last year
    >and this works just fine for me
    >
    ># No shebang !!
    >use strict;
    >use warnings;
    >
    >print STDERR "\nHello world\n";
    >
    >exit(0);
    >
    >
    >I just tried changing the first line so I now have
    >
    >#!/usr/local/bin/perl
    >use strict;
    >use warnings;
    >
    >print STDERR "\nHello world\n";
    >
    >exit(0);
    >
    >and this also runs with no problems.
    >
    >As far as I am aware any line starting with a hash will be treated as a
    >comment under windoze.


    Well, that may work when running a simple Perl script as above from a
    command line. But my script is a Server Side Include (SSI) file which
    needs some setup in the Apache Web Server. Making the modfication you
    suggest just gives me [an error occurred while processing this
    directive] on my webpage.
    The Path to the perl.exe is set in my PATH. But Apache web server
    doesn't seem to have anywhere to associate .pl scripts to the perl.exe
    interpreter. It mentions that *.pl files are CGI scripts, but not
    which interpreter specifically will be started by Apache when the
    script is invoked.

    But, thanks for your help anyway.

    Anyone else know how to do this?
    Test Test., Apr 28, 2006
    #7
  8. Josef Moellers <> wrote:

    > the deprecated '-w'



    The term "deprecated" has a precise meaning, and I am pretty
    sure that we cannot apply it to the warnings switch yet.

    the superceded '-w'
    or
    the not-as-good-as-use-warnings '-w'

    would be accurate.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 28, 2006
    #8
    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. BBeasley

    Browser compatability

    BBeasley, Jan 17, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    376
    Showjumper
    Jan 18, 2004
  2. =?Utf-8?B?RGluZXNo?=

    File compatability between VS.NET and Web Marix

    =?Utf-8?B?RGluZXNo?=, Mar 2, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    404
    Chris Jackson
    Mar 3, 2004
  3. abbu
    Replies:
    1
    Views:
    293
    Ben Pope
    Mar 20, 2006
  4. Harry
    Replies:
    2
    Views:
    456
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Mar 28, 2007
  5. Ron D
    Replies:
    2
    Views:
    77
    Lasse Reichstein Nielsen
    Dec 16, 2003
Loading...

Share This Page