XAMPP/PERL file extentions

Problems with the Windows version of XAMPP, questions, comments, and anything related.

XAMPP/PERL file extentions

Postby nzmehere » 23. November 2009 19:44

Hi Everyone,

I've installed XAMPP have a situation where an application I want to run doesn't have file extentions on it's files.
The files are Perl.

@ the top of every file there is the directive:
#!/usr/bin/perl -w

Since I am running windows, this path is obviously wrong.
I have tired updating it to correct path, but still the file won't be parsed as Perl.

The 2 options I see (and need input on) are:
1. Get the "#!/usr/bin/perl -w" directive working
2. get Apache to render all files with no extension as Perl. (preferably using .htacess)

I've asked Mr Google about this but haven't found an answer as yet.

Does anyone here have an suggestions on how to do either/both of the above?

Thanks!
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00

Re: XAMPP/PERL file extentions

Postby Izzy » 24. November 2009 00:31

Missing support info - what XAMPP version and which Windows OS?
So assuming latest stable XAMPP version.
nzmehere wrote:@ the top of every file there is the directive:
#!/usr/bin/perl -w
This is the shebang using the default Linux path but should be the path to perl in your XAMPP for Windows installation which is usually:
#!"C:\xampp\perl\bin\perl.exe -w"
The -w switch relates to:
enable many useful warnings (RECOMMENDED)

perl -h command in a command console, or use the Shell button in the XAMPP Control Panel, will provide a list of all switches.

In Windows the shebang is best using the full path to perl including perl.exe with the file extension, inside quotation marks but I have also been able to get it to work by just using the full path to perl with no file extension for example, in the Shell console window and the shebang #!"C:\xampp\perl\bin\perl -w"

Look in the \xampp\cgi-bin folder for an example perl script that has the shebang at the top of the file:
printenv.pl
As a test type http://localhost/cgi-bin/printenv.pl in your browser which should print back your PC's environment variables.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: XAMPP/PERL file extentions

Postby nzmehere » 24. November 2009 19:01

Hi.

Thanks for answering.

Sorry about not outlining my environment!
I am running XAMPP for windows 1.7.2 - latest build, on Windows7 Pro.

I tried what you suggested with the following steps:

1. Copied the perlinfo.pl filein to a dir off the webroot called "perltest"
Updated the top line to be:
Code: Select all
#!"C:\resources\xampp\perl\bin\perl.exe"

- that's the path to my install. Pretty standard, just in a "resources" sub folder.

The full code reads:
Code: Select all
#!"C:\resources\xampp\perl\bin\perl.exe"

use HTML::Perlinfo;
use CGI qw(header);

$q = new CGI;
print $q->header;

$p = new HTML::Perlinfo;
$p->info_general;
$p->info_variables;
$p->info_modules;
$p->info_license;


2. Ran the perlinfo.pl file and got the expected output.
All good so far.

3. Renamed the "perlinfo.pl" file to "perlinfo"
4 Ran the file and the code was output

My expectation (rightly or wrongly) was that the "#!"C:\resources\xampp\perl\bin\perl.exe"" would tell Apache to parse this file using that EXE.
So it seems that directive isn't being respected by the server.
Is this a setting I need to set some where, or am I missing something else?

Thanks again for you help!

Cheers
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00

Re: XAMPP/PERL file extentions

Postby nzmehere » 01. December 2009 05:29

I tried this with PHP files without extentions too.

EG:

Code: Select all
#!"C:\resources\xampp\php\php.exe"
<?php phpinfo() ?>


and

Code: Select all
#!"C:\resources\xampp\apache\bin\httpd.exe"
<?php phpinfo() ?>


Does this mean XAMPPs Apache doesn't respect that directive, or am I missing something?

Cheers
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00

Re: XAMPP/PERL file extentions

Postby Wiedmann » 01. December 2009 08:43

I've installed XAMPP have a situation where an application I want to run doesn't have file extentions on it's files.
The files are Perl.

You have enabled or disabled mod_perl? (just to know which solution is right for you)

My expectation (rightly or wrongly) was that the "#!"C:\resources\xampp\perl\bin\perl.exe"" would tell Apache to parse this file using that EXE.

Apache is only looking for a shebang, if it know that it should tread a file as cgi.

BTW:
In cgi-bin Apache is already doing what you want.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: XAMPP/PERL file extentions

Postby nzmehere » 01. December 2009 18:53

Hi There,

I very new to this, so sorry for the newbie type questions/answers.

I download XAMPP 1.7.2 for Windows, and from what I have read I *think* mod_perl is enabled.
When I run a perl file with a ".pl" extension it works fine.

The 3rd party application I am looking at is written in Perl, but their files have no extension at all.
I've worked out how to use .htaccess to set a default type for files, but don't know how to make it so that the default type is Perl.

The main goal is to get the extention-less files to run as Perl.

All the files in the application have the #![path to perl] in the top, but even when that points to the correct Perl path it's not respected.

The preferable option I would like would be to use .htaccess (or something) to run the files in this application as Perl, as I like the idea of not having to modify the code base to do what I need.

Your comment about cgi/shebang, is there a way I can use the DefaultType in .htaccess to so this?

I'll have a look to see what I can work out, but any help suggestions/pointers would be great!
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00

Re: XAMPP/PERL file extentions

Postby Wiedmann » 01. December 2009 19:12

I download XAMPP 1.7.2 for Windows, and from what I have read I *think* mod_perl is enabled.

Correct, so the question is:
Have you disabled it?

All the files in the application have the #![path to perl] in the top, but even when that points to the correct Perl path it's not respected.

As I have written, Apache is only looking at the shebang, if it knows it's a CGI. And it doesn't know this for a file without an extension.

is there a way I can use the DefaultType in .htaccess to so this?

Sure, and that's the reason I need an answer to my first question.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: XAMPP/PERL file extentions

Postby nzmehere » 01. December 2009 20:05

Hi there,

To answer your first question: "Have you disabled it?"
- Not that am I aware of!
I don't think I have. How do I confirm/check?

I haven't done much with the default config of the XAMPP install, but may have done something without realising.

Thanks for the help!
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00

Re: XAMPP/PERL file extentions

Postby Wiedmann » 01. December 2009 21:12

Well, with mod_perl that should be something like:
Code: Select all
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule !^.+\..+$ - [H=perl-script]
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: XAMPP/PERL file extentions

Postby nzmehere » 02. December 2009 00:23

Hi There,

I put that code in my .htaccess in the folder and it worked!

Thank you so much for your help!

Awesome
nzmehere
 
Posts: 6
Joined: 23. November 2009 19:00


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 82 guests