To the best of my knowledge, the #! line on a Windows NT script does nothing. NT does not understand it, instead it uses file associations to know how to execute a script. You should be able to use #!/usr/bin/perl in the scripts on the NT side with no problem and be able to move them over to the Unix side of the house quite easily. We do something similar. We have both Unix and NT Perl scripts that are based on the same outline. All the scripts have the #!/usr/bin/perl line, regardless of which platform they are on and they run fine. | [reply] |
To the best of my knowledge, the #! line on a Windows NT script does nothing.
That's not quite true. In Windows, perl checks the #! line for options. For example, #!/usr/bin/perl -w will turn on warnings. However, everything else you said applies because the path itself is not used. In other words, there's nothing wrong in putting #!/usr/bin/perl in the Windows versions of your scripts, because neither Windows nor perl uses that part of the #! line.
| [reply] [d/l] [select] |
Didn't know that part about the switches, thanks for the info.
| [reply] |
For CGI, you can make a drive:\usr\bin\perl.exe copy on your development NT box. It only needs to contain the exe, as the dll's will be found in the proper place.
#! /usr/bin/perl -w
use strict;
print "Content-Type: text/plain\n\n";
printf("perl executable %s\n",$^X);
printf("perl version %vd\n",$^V);
Apache returns:
perl executable I:\usr\bin\perl.exe
perl version 5.8.6
update: I forgot to 'use strict' ;) | [reply] [d/l] |
This was the easiest solution that works without changing anything. I am running apache webserver on NT and "#!/usr/bin/perl" now works on NT after creating the path.
| [reply] |
a minor add to ikegami's observation (above):
This also depends on what server you're running on the Win platform. The Xitami server, for example, wants a shebang that includes the executable name.ext, thusly:
#!C/perl/bin/perl.exe
(Correct; it doesn't care which way the slashes tilt) whereas Apache (at least 1.2, etc under w2k) is more "standard" in that it does NOT want the executable named; something I think is also the case in WinNT's built-in.
Suggest you see if your scripts run ok on your windows machine with a *nix-ish shebang. | [reply] |
well, one way to do it would be to add /usr/bin to your path on the nix box (but that may not be advisable for other reasons). On most Win installations, typically <root>:\perl gets added to the env variable PATH. Now you can safely type the following on your shebang line
#!perl
Of course, as others have mentioned, on Win, file associations also come into play. That, however, is not always reliable. Typically .pl (or .plx) is associated with the perl binary, so .cgi would not be. Of course, typing
prompt>perl myscript.whateverextension
would work because perl itself is in the path.
And, as ikegami said, the shebang line is _the_ place for the switches. | [reply] [d/l] [select] |