1
votes

Recently I installed XAMPP (Apache) server for running CGI script on windows machine. As you know, XAMPP has the option to install PERL but i didn't select it, i want to use Cygwin's PERL for executing those.

Problem is when I'm trying to run a basic CGI script , I get the following error

[Tue Sep 20 19:51:10.473825 2016] [win32:error] [pid 12420:tid 1848] [client ::1:57051] AH02102: C:/xampp/cgi-bin/perltest.cgi is not executable; ensure interpreted scripts have "#!" or "'!" first line`enter code here`

[Tue Sep 20 19:51:10.473825 2016] [cgi:error] [pid 12420:tid 1848] (9)Bad file descriptor: [client ::1:57051] AH01222: don't know how to spawn child process: C:/xampp/cgi-bin/perltest.cgi

Meaning the Cygwin Perl path is not vaild. However , I did change the path and put a shebang still its now working . This is the one i'm using:

#!C:\cygwin64\bin\perl.exe

Any help is appreciated

2
Which version of cygwin's PERL are you using? Did you installed PERL extensions with the cygwin setup? Check your $_PATH enviroment variable to see if the correct PERL path is included - Manuel Azar
I'm using (v5.22.1)...I don't think of installing any extension .. How to check the $_Path environment variable..any help.. - Randy
Ahh my bad.......its solve now..... while pasting or changing the shebang...it moved to 2nd line and was making it not to work....its working now....Disregard it...thanks for the help - Randy
The shebang line is usually ignored by the interpreter because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments still may ignore the shebang line in recognition of its purpose - Manuel Azar

2 Answers

0
votes

The shbang concept doesn't exit on Windows. Apache is known to have emulated the concept of shbang on Windows (by reading the first line of the script), but still there may be problems.

Better thing is just use Windows batch files (.bat files) on Windows as CGI scripts (you can also use .vbs).

Just do the SetHander (or AddHandler) for the particular type of script in Apache's configuration and then use a batch file like HelloWorld.bat.

@echo off
echo "content-type: text/plain"
echo.
echo "Hello World"
dir

In place of dir you can substitute any other binary (such as perl.exe).

0
votes

While pasting or changing the shebang, it moved to the second line and was making it not work, but it's working now.