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

J

joe

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
 
J

James Willmore

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
 
J

Josef Möllers

joe said:
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.
 
J

joe

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
 
B

Bob X

joe said:
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.
 
S

Sam Holden

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

Louis Erickson

:> :> 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?
 
B

Bob X

Louis Erickson said:
:> :> 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?
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).
 
M

Matthias Weckman

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

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top