Linux and Win32 compatability

T

Test Test.

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
 
N

niall.macpherson

Test said:
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.
 
P

prawn

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

Josef Moellers

Test Test. wrote:




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

A. Sinan Unur

Test Test. said:
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 <[email protected]>
(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
 
G

Gunnar Hjalmarsson

Test said:
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 --

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
 
T

Test Test.

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?
 
T

Tad McClellan

Josef Moellers said:
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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top