Page 1 of 1

Perl error message

PostPosted: 26. May 2010 10:51
by mrsmith
Hi,

I have installed on XAMPP on Windows XP 32-bits and apache server works perfectly well except perl.

I have two version of hello.pl and hello-oo.pl. (oo = object oriented)

I attempted to execute it by typing 192.168.1.25/cgi-bin/hello.pl (hello-oo.pl too)

The source code for hello.pl is:

#!/usr/bin/perl

use strict;
use CGI ':standard';

print header;
print start_html('Hello World');
print h1('Hello World');
print end_html();

exit;

And oo version is:

#!/usr/bin/perl

use strict;
use CGI;

my $cgi = new CGI;

print $cgi->header;
print $cgi->start_html('Hello World');
print $cgi->h1('Hello World');
print $cgi->end_html();

exit;

The error messages in apache error.log are:

The system cannot find the path specified. : couldn't create child process: 720003: hello-oo.pl
The system cannot find the path specified. : couldn't spawn child process: C:/xampp/cgi-bin/hello-oo.pl
The system cannot find the path specified. : couldn't create child process: 720003: hello.pl
The system cannot find the path specified. : couldn't spawn child process: C:/xampp/cgi-bin/hello.pl

How can I do to resolve it?

Thanks kindly in advance

M

Re: Perl error message

PostPosted: 26. May 2010 11:01
by Nobbie
mrsmith wrote:#!/usr/bin/perl


You have Perl installed in /usr/bin on your Windows PC?

Re: Perl error message

PostPosted: 26. May 2010 11:53
by mrsmith
Yes i have installed perl on Windows XP at c:\perl

Re: Perl error message

PostPosted: 26. May 2010 12:12
by Altrea
mrsmith wrote:Yes i have installed perl on Windows XP at c:\perl

So, why does your shebang route to folder usr/bin/perl?

mrsmith wrote:
Code: Select all
#!/usr/bin/perl

Re: Perl error message

PostPosted: 26. May 2010 12:37
by mrsmith
Hi,

I am newbie on perl programming.

I was following the "Hello World" programming exercise from the book "SAMS Teach yourself CGI in 24 hours".

What is the correct statement? What it should be? "c:\perl"?

Thanks in advance

Mike

Re: Perl error message

PostPosted: 26. May 2010 12:50
by Altrea
Code: Select all
#!C:\Perl\bin\perl.exe


or something which is correct on your Perl installation path

Re: Perl error message

PostPosted: 31. May 2010 00:40
by MC10
I think you need to use forward slashes, not backslashes, like so:

Code: Select all
#!C:/Perl/bin/perl.exe

Re: Perl error message

PostPosted: 31. May 2010 02:41
by JonB
uhhh - aren't we talking about a XAMMP install on windows??

I think XAMPP wants to use its 'own' Perl. (and you may need to turn mod_perl off).

This is the setting from my YaBB board. i.e. I know it works, LOL. :wink:

Code: Select all
#!C:/xampp/perl/bin/perl.exe


Perl escapes the slashes in a Windows environment.

An ActiveStates install will put Perl in c:\perl by default (I have Active States 5.10 installed as well, but XAMPP uses the Perl dlls found in /perl/bin - I have been working to get a new port of Webmin to run, so I have been experimenting with these) No dice on Webmin on windows for 5.10 Perl :(

Good Luck

8)

Re: Perl error message

PostPosted: 31. May 2010 04:58
by Altrea
MC10 wrote:I think you need to use forward slashes, not backslashes, like so:

Code: Select all
#!C:\Perl\bin\perl.exe

Thank you very much for the correction.
I get fooled from one of the perl tutorials out in the web which uses Backslashes in the shebang :D

Re: Perl error message

PostPosted: 31. May 2010 10:28
by peterwt
Using xampp ver 1.6.4 under Windows Vista.

I have just come across this problem.

All the Perl scripts I have written in the past work. I wanted to experiment with cookies using Perl.

The line use CGI;, which I have not used before, but is in the cookie script, is causing the problem. The error log points to this line.

As I understand it, CGI is a module which appears to be missing. In xampp/perl/bin there is only perl.exe.

The script works when I upload to my hoating site.

How do I get CGI module installed?

By the way if you are running xampp under Windows you can change in httpd.conf -

# To enable the this Windows specific behavior (and therefore -disable- the
# equivilant Unix behavior), uncomment the following directive:
#
ScriptInterpreterSource registry

and set the default program for .pl or .cgi files to run perl.exe then the shebang line in Perl scripts will be ignored.

Peter

Re: Perl error message

PostPosted: 31. May 2010 14:19
by JonB
peterwt:

You didn't give the actual error. or the code that created it.

CGI:: is a Perl MOD, not a dll or exe. Its a piece of Portable Perl. Perl has repository systems and Module Managers, much like PHP or Linux. Google 'CPAN' and 'PPM'.

the CGI Perl mod is installed. Look on your XAMPP Perlinfo page (give it a chance to complete). Down in All Perl Mods you will find CGI 3.48 Handle Common Gateway Interface requests and responses. I know it (CGI) works cause my forum software uses it for cookies and doing uploads.

Its only a guess, but CGI needs a temporary workspace, you may need to create a directory called c:\temp. Otherwise it uses the PWD, or the root of the script (as I recall) in that order. You can define the location with an environment variable, I think.

Re: Perl error message

PostPosted: 31. May 2010 15:41
by peterwt
jonB:

Thanks for your reply. I am usung xampp ver 1.6.4 which seems to have a basic version of Perl. in the xampp/perl/bin folder there is only perl.exe.

I can not find perlinfo, only phpinfo.
I have had no problems in scripts until I tried one to use cookies. This is the first script I have put the directive CGI;
Code: Select all
#!/usr/bin/perl -w

use CGI qw(:standard);
#rest of script


The errors I get are -
[Mon May 31 15:22:21 2010] [error] [client 127.0.0.1] Premature end of script headers: cookies.cgi, referer: http://localhost/Ptest.html
[Mon May 31 15:22:21 2010] [error] [client 127.0.0.1] Can't locate CGI.pm in @INC (@INC contains: .) at C:\\xampp\\htdocs\\mysites\\cgi-bin\\cookies.cgi line 3.\r, referer: http://localhost/Ptest.html
[Mon May 31 15:22:21 2010] [error] [client 127.0.0.1] BEGIN failed--compilation aborted at C:\\xampp\\htdocs\\mysites\\cgi-bin\\cookies.cgi line 3.\r, referer: http://localhost/Ptest.html

This points to line 3 - use CGI qw(:standard);

It appears that my perl does not have CGI module.

Peter

Re: Perl error message

PostPosted: 31. May 2010 16:01
by JonB
peter:

I spent the time to extract XAMPP 1.6.4, you are correct, and that version would require a good amount of work to make it a workable Perl environment. The is no 'lib' folder included.

Unless there is some overriding reason, I would simply suggest you get on the current version, it has a well developed and rich Perl environment. If you are going to write and test scripts, take the time to upgrade (its a reinstall) -- I don't know what else you have in that environment, but working with Perl will be torturous.

If you don't have things to save, for sure make the upgrade. If you only have HTML files, save the htdocs folder to a location outside XAMPP.

If you have other projects such as PHP or MySQL databases, the process should not so bad. Dump the databases, and save all your settings in text files, Save your htdocs folder by copying it to a secure location and so forth.

I'm not trying to give you a comprehensive guide to upgrading, just saying to get your ducks in a row first

BTW, even if the installation does not require a shebang line, it serves another function - (hint) to tell you where to look for components.


The Good News:

XAMMP 1.7.3 comes with a fairly tricked out set of Perl Mods aleady in place. Some mods are windows or *nix specific (mostly ones for system functions), and won't work in all environments, so you may not find them in all installations. I was able to get every one of my apps running with no Mod's needing installation (which is not true for ActiveStates), other than the Webmin port which is dependent on one of those OS specific Perl mods that is not available in the current version 5.10.

Good Luck
8)

Re: Perl error message

PostPosted: 01. June 2010 10:04
by peterwt
JonB:

Many thanks.

Looking at the version history of XAMPP it shows that Perl Add-In was not included in the distribution until version 1.7.2, after the version I have.

I downloaded a current version of Perl with library and modules and it now works.

Peter

Re: Perl error message

PostPosted: 01. June 2010 11:50
by JonB
Great -

Perl is not the darling of the webworld it once was, but it is a tool you can do almost anything with (including writing free-standing programs that can be compiled into executables - take THAT, PHP!, LOL).

Good Luck
8)