Re: shebang line for Perl scripts under Apache/Windows
by mpeters (Chaplain) on Jan 12, 2005 at 14:32 UTC
|
"Somebody mentioned on the Chatterbox that I might be using an extra SetHandler in Apache's configuration file, bypassing Windows' file association, but that's all he said about it. Anybody know if/how that would work? Or of any other alternatives?"
Not SetHandler (unless you want to do it for specific location/directory) but AddHandler, should do the trick. Try something like this in your apache config file:
AddHandler cgi-script .cgi
This directive is only available with mod_mime (which is installed by default) and can work globally, or inside of a Location/Directory. You can read this for more information. | [reply] [d/l] |
|
|
Unless I'm badly mistaken, that won't solve the stated problem, as the handler cgi-script uses checkes the file's shebang to determine which script to execute. Which is the whole problem =]
| [reply] |
Re: shebang line for Perl scripts under Apache/Windows
by sasikumar (Monk) on Jan 12, 2005 at 11:33 UTC
|
you can create same directory structure in both windows and linux and install perl there. In linux create the directory with the drive name so it would find out.
Update: In case of windows just create a directory with /usr/bin/ so it would resolve the problem.
| [reply] |
|
|
Yes erix pointed to one of his replies in an earlier tread which describes such a solution, in the Chatterbox. I guess it works... though it's an ugly hack, and I'm not sure what drive the directory has to be on, in order for it to work reliably. Apache's? The website's?
| [reply] |
|
|
It works fine and makes switching machines really simple, at least for me. The drive perl has to be on is which ever drive apache's CWD is on. So if apache's cwd is "C:/foo/bar/", "/usr/bin" will refer to "C:/usr/bin". But if apache starts under D: or some such, it needs to be there. Also note, last I checked, you don't need the entire perl install in this new directory, you can simply add a shortcut named perl, and that should work.
| [reply] |
Re: shebang line for Perl scripts under Apache/Windows
by doink123 (Sexton) on Jan 12, 2005 at 11:21 UTC
|
If the perl executable is in the PATH environment variable on both operating systems (most probably it is if you are using ActivePerl on windows) then you can only use
#!perl
it should run both on windows and linux | [reply] |
|
|
perl: bad interpreter: No such file or directory
Of course your experience may be different.
/J\
| [reply] [d/l] [select] |
|
|
It checks the shebang line, ignoring the file association of the file extension. If you use a full path, it must exist — though something as generic as just "perl" works too.
he said that.
"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce
| [reply] |
Re: shebang line for Perl scripts under Apache/Windows
by dragonchild (Archbishop) on Jan 12, 2005 at 15:02 UTC
|
Instead of using Apache for Windows, why not use Cygwin and compile Apache under it? Granted, it is 30%-50% slower than on Linux, but for personal testing, that shouldn't be an issue ...
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
Re: shebang line for Perl scripts under Apache/Windows
by strat (Canon) on Jan 13, 2005 at 08:04 UTC
|
if apache and the website(s) (are on the same drive, and if you really need to keep the assoctiation of .cgi to your text editor, you could install perl to DRIVE:\usr (but only install perl into that dir, don't add other software...), so that perl can be reached by DRIVE:\usr\bin\perl.exe, and then the shebang /usr/bin/perl should work... (haven't tested it)
But I prefer the way associating .cgi with perl.exe and
ScriptInterpreterSource Registry in httpd.conf
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
| [reply] [d/l] |
Re: shebang line for Perl scripts under Apache/Windows
by jZed (Prior) on Jan 12, 2005 at 19:30 UTC
|
| [reply] |
|
|
Like I said: that doesn't work, because *.cgi scripts are associated with my text editor.
| [reply] |
Re: shebang line for Perl scripts under Apache/Windows
by cosmicperl (Chaplain) on Nov 24, 2014 at 10:19 UTC
|
Hi,
What you are looking for is possible by updating your registry to have an ExecCGI key:
Apache 2 ScriptInterpreterSource documentation
That way you can still have your text editor association when you double click in Windows explorer and alike, but have apache read from the registry and ignore the shebang line. | [reply] |
|
|
On windows install Perl in c:/usr/bin/ or whatever path your remote machine has
| [reply] |