cgi error question

IBhacknU

Diamond Member
Oct 9, 1999
6,855
0
0
Trying to set-up a guestbook and my server is showing this error:

(2)No such file or directory: couldn't spawn child process: c:/program files/apache group/apache/cgi-bin/guestbook.cgi

What does the couldn't spawn child process part mean? I know the directory and file are valid.
 

Rendus

Golden Member
Jul 27, 2000
1,312
1
71
In this case it means one of two things, not sure which:

It means either that cgi file you're trying to access isn't actually there, or the interpreter for the CGI file (perl, bash, whatever) is missing (or the path to it is wrong).
 

konichiwa

Lifer
Oct 9, 1999
15,077
2
0
Check your path (most likely perl) -- make sure it's really pointing to the perl interpreter. Also, it looks like it's pointing to a local file, unless you have Apache running on your system that might be the problem. :p
 

IBhacknU

Diamond Member
Oct 9, 1999
6,855
0
0
OK... here's the set-up:

The Apache is running on a Win98 server. Perl is located at C:/perl. I have tested the perl install, and according to the 'self test' it works.

The first line of my script contains: #!C:/perl (or should it be #!C:\perl)?? This is to point the cgi script to the interpreter. I have also tried #!C:/perl/bin (and #!C:\perl\bin/) as that's where the perl 'application' is located.

Script alias for cgi is enabled in the apache config and points to the proper directory.

All of the tutorials I have read are geared to unix and I'm getting lost trying to set this up. Is there a simple script I can use to test the cgi? I may not have the guestbook configured properly, thus the error? Even so, the original error couldn't spawn child process still confuses me.
 

IBhacknU

Diamond Member
Oct 9, 1999
6,855
0
0
You were all testing me... right? Well, instead of searching for PRON pictures tonight, I figured out this DAMN perl/cgi/apache stuff and best of all IT WORKS!

The path was right, but I needed to specify the .exe file as well.

Apache provides an emulation of the UNIX shebang (#!/path/to/perl) syntax, so the next step is easy. You can put you Perl scripts into your cgi-bin directory, as long as you have a path to a valid interpreter at the top. For example:

#!C:\PERL\perl.exe


DUH!

For those who find this later using the search function, here is a list of links and snips you may (or may not) find helpful:



The really helpful stuff

velocity.activestate.com/docs/ActivePerl

velocity.activestate.com/docs/ActivePerl/faq/Windows/ActivePerl-Winfaq6.html

How do I use ActivePerl under Apache?
If you want to put all of your CGI scripts into one directory, add the following line to your srm.conf file (You can choose any directory you'd like, but make sure it exists):

ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"

After you have made this change, stop and restart the Apache service.

Apache provides an emulation of the UNIX shebang (#!/path/to/perl) syntax, so the next step is easy. You can put you Perl scripts into your cgi-bin directory, as long as you have a path to a valid interpreter at the top. For example:

#!C:\PERL\5.00464\bin\MSWin32-x86\perl.exe

use CGI qw:)standard) ;
print header();
print "Hello, world";

If you want to enable CGI scripts based on an extension, such as .pl, you need to add the following line to srm.conf:

AddHandler cgi-script .pl

By default, CGI scripts are not allowed in your DocumentRoot directory, but they are allowed in other document directories. Document directories are created with the Alias command in srm.conf:

Alias /ResourceKit/ "E:/utilsamp/"

You can then include files that end in .pl within a document directory. You will still need to include the #! line with the full path to the perl.exe interpreter, as shown earlier.

If you want to allow CGI scripts in the DocumentRoot directory, add the ExecCGI option to the Options directive between the <Directory> and </Directory> entry for your DocumentRoot in access.conf (these appear directly after the comment titled:

# This should be changed to whatever you set DocumentRoot to.

After you have updated it, your Options directive may look something like:

Options Indexes FollowSymLinks ExecCGI


perl.apache.org/

and other stuff

www.postino.com/aldham/cgi.html

www.cpan.org/doc/FAQs/cgi/perl-cgi-faq.html

www.jmarshall.com/easy/cgi/



What are these codes in the perl script:
1. The first line tell the shell how to run perl on your computer- since we have the perl.exe files in the same directory as the *.pl program scripts this line is actually not necessary.
#!perl.exe

www.pconline.com/~erc/perl95.htm

Add \perl\bin (or \perl5\bin) to your PATH

www.pconline.com/~erc/perlwin.htm

Even though it may seem different at first, you run your Perl scripts on Windows the same way you do on UNIX: from a command line. On Windows, this means you run your Perl scripts from an MS-DOS Prompt window. For example:
C:\> perl hello.pl

Paths

Windows uses a backslash character, \, to separate directories. UNIX uses a forward slash character, /. To make matters worse, the backslash is a special character in Perl. Because of this, you need to use two backslashes (the first &quot;escapes&quot; the second) for paths on Windows. For example:

C:\\PERL

Because of this, you have to be careful how you put together paths on Windows.


************** further more ************

On UNIX and Linux, you can change a Perl script into an executable file with two steps:

Mark the file as executable.
Place a special comment into the first line of the Perl script. This comment identifies the shell program that should be run on the script, for example:

#!/usr/bin/perl


This won't work on Windows!

Why? Because Windows does not provide shells like UNIX. The special comment #!/usr/bin/perl works because UNIX shell programs have code that looks at a specially-formatted comment in the first line of the script to determine which program to launch to handle the script.

Since MS-DOS doesn't support these special comments, this technique won't work on Windows.

The way around this is to convert your Perl files into DOS batch files.

************ and finishes by saying ***********

Note: The latest Perl for Win32 no longer needs to convert Perl scripts to DOS batch files, since Perl now sets up entries in the Windows registry.

The neat-o pl2bat.bat batch file can convert your Perl script into a DOS batch file. This takes advantage of the fact that DOS and Perl can interpret the same instructions--if carefully formatted--differently.

The command:


C:\> pl2bat hello.pl

converts hello.pl to hello.bat, a DOS batch file. If you look in this file, you'll see your Perl script wrapped inside a DOS batch file. You can then simply invoke the batch file, by typing the name of your file (without the .bat extension) as you do with normal DOS batch files.

The script takes advantage of a clever idea. The following lines are both valid Perl (setting the @rem array to a multi-line string) and DOS batch syntax (comments):


@rem = '
@rem ';

In between the two lines, the pl2bat.bat script places a set of DOS batch commands that invoke the Perl command with the rest of the file.

Try it out and look at the resulting file. It's really quite clever.

On Windows, double-clock on any file in the Perl Doc directory. (The Windows Perl manual pages are in HTML Web format.)
 

unxpurg8d

Golden Member
Apr 7, 2000
1,373
0
71


LOL IBhacknU - if it makes you feel better about all that missed nekkid pic time I printed that lovely explanation of yours out to save for future reference. :p