Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Linux and Win32 compatability

Reply
Thread Tools

Linux and Win32 compatability

 
 
Test Test.
Guest
Posts: n/a
 
      04-28-2006

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
 
Reply With Quote
 
 
 
 
niall.macpherson@ntlworld.com
Guest
Posts: n/a
 
      04-28-2006

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.

 
Reply With Quote
 
 
 
 
prawn
Guest
Posts: n/a
 
      04-28-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
Josef Moellers
Guest
Posts: n/a
 
      04-28-2006
(E-Mail Removed) 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

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      04-28-2006
Test Test. <> wrote in news:(E-Mail Removed):

>
> 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...erpretersource

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 <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html

 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      04-28-2006
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....01d5affb0294e8

and then a more elegant(?):

http://groups.google.com/group/comp....026827a583f19d

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
Test Test.
Guest
Posts: n/a
 
      04-28-2006
On 28 Apr 2006 02:11:19 -0700, (E-Mail Removed) 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?
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      04-28-2006
Josef Moellers <(E-Mail Removed)> 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
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IS their compatability issues with AVG and xp sp2? George Computer Support 2 01-04-2005 09:27 PM
Catalyst 3548 and 3550 Compatability Gary Cisco 1 12-07-2004 05:13 AM
Hmmm... problems with CPAN (MakeMaker?) on Win32+MSYS or Win32+UnixUtils and others Alex Lyman Perl 0 03-07-2004 05:10 PM
File compatability between VS.NET and Web Marix =?Utf-8?B?RGluZXNo?= ASP .Net 4 03-03-2004 05:05 PM
Win32::SAPI4 question (Win32 events and Perl) Michael Edmonson Perl Misc 0 02-28-2004 03:20 AM



Advertisments