script not found or unable to stat

Alles, was Perl betrifft, kann hier besprochen werden.

script not found or unable to stat

Postby u671296 » 22. November 2009 02:19

Hi,
I'm new to Apache admin, so sorry for a probably dumb question. any help appreciated.
HTML is served up fine on my Windows based server.

Now I am trying to access a Perl script I am using Apache 2.2 and ActivePerl and get the error:
[client 127.0.0.1] script not found or unable to stat: C:/Program Files/Apache/Apache2.2/cgi-bin/first.pl

However this did work once only the first time I ran this "Hello World script"
#!C:/Perl/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";

After then adding a second print statement
print "Hello, again World";
I now get the script not found error and cannot make it work again. Removing the line makes no difference. Restarting Apache, opening a new browser also makes no difference.

The Perl executable is C:\Perl\bin\perl
The cgi-bin directory is C:\Program Files\Apache\Apache2.2\cgi-bin

My httpd.conf (most comments stripped out) is as follows:

ThreadsPerChild 250
MaxRequestsPerChild 0


ServerRoot "C:/Program Files/Apache/Apache2.2"

Listen 80

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule headers_module modules/mod_headers.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule status_module modules/mod_status.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so

ServerAdmin malcolm@hogson.wanadoo.co.uk

ServerName http://www.malcolmhodgson.com:80

DocumentRoot "C:/Program Files/Apache/Apache2.2/htdocs"

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>

<Directory "C:/Program Files/Apache/Apache2.2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>
<Directory "C:/Program Files/Apache/Apache2.2/cgi-bin">
Options Indexes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>

ErrorLog logs/error.log

LogLevel debug

<IfModule log_config_module>
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>

CustomLog logs/access.log common

</IfModule>

<IfModule alias_module>
ScriptAlias /cgi-bin/ "C:/Program Files/Apache/Apache2.2/cgi-bin/"

</IfModule>

<Directory "C:/Program Files/Apache/Apache2.2/cgi-bin/">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types

#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi

# For type maps (negotiated resources):
#AddHandler type-map var

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.malcolmhodgson.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
# starting without SSL on platforms with no /dev/random equivalent
# but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Last edited by u671296 on 22. November 2009 23:16, edited 1 time in total.
u671296
 
Posts: 4
Joined: 22. November 2009 01:58

Re: script not found or unable to stat

Postby Nobbie » 22. November 2009 13:29

You probably did edit your script with Notepad and it added extension *.txt when saving the file?!
Nobbie
 
Posts: 6778
Joined: 09. March 2008 13:04

Re: script not found or unable to stat

Postby u671296 » 22. November 2009 19:02

Hi,

No. I was aware of that potential problem. Thanks anyway.
u671296
 
Posts: 4
Joined: 22. November 2009 01:58

Re: script not found or unable to stat

Postby Izzy » 23. November 2009 01:43

Check your Apache server error log file - \apache\logs folder.

Are you trying to call the script by this?
http://localhost/cgi-bin/first.pl

or with:
http://www.malcolmhodgson.com/cgi-bin/first.pl

Try dropping the http:// part in the ServerName to www.malcolmhodgson.com

Try this shebang:
#!"C:\Perl\bin\perl.exe"

And include the quotation marks when using a Windows path especially when they have spaces in the file or folder name - best to install Apache to a root folder like C:\apache and the Apache server is case sensitive.

ServerName http://www.malcolmhodgson.com:80
This domain does not exist from the Internet.

Have you created a Windows hosts file entry so you can access that address locally?
127.0.0.1 www.malcolmhodgson.com

Does your Windows hosts file also contain as the first uncommented entry?
127.0.0.1 localhost

Finally clear your browser's cache often when working at localhost level or you may unexpectedly receive a cached page from the browser instead of a fresh page from the server.
Last edited by Izzy on 24. November 2009 01:12, edited 1 time in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: script not found or unable to stat

Postby Nobbie » 23. November 2009 09:30

Or maybe you edited with an UTF8-enabled editor and it inserts the (fairly invisible) BOM-Header, making the Shebang-Line not the the very first line.
Nobbie
 
Posts: 6778
Joined: 09. March 2008 13:04

Re: script not found or unable to stat

Postby u671296 » 24. November 2009 01:04

Nobbie wrote:Or maybe you edited with an UTF8-enabled editor and it inserts the (fairly invisible) BOM-Header, making the Shebang-Line not the the very first line.

Possibly, but I'm using notepad which I don't think is enabled to do anything much. Not even editing non-.txt files :lol:
I'm using Save-as and selecting Save as type - All Files and ANSI.
u671296
 
Posts: 4
Joined: 22. November 2009 01:58

Re: script not found or unable to stat

Postby u671296 » 24. November 2009 02:01

Izzy wrote:Check your Apache server error log file - \apache\logs folder.

Are you trying to call the script by this?
http://localhost/cgi-bin/first.pl

This gives:
[client 127.0.0.1] script not found or unable to stat: C:/Apache/Apache2.2/cgi-bin/first.pl


This also gives:
[client 127.0.0.1] script not found or unable to stat: C:/Apache/Apache2.2/cgi-bin/first.pl

Izzy wrote:Try dropping the http:// part in the ServerName to www.malcolmhodgson.com

This also gives:
[client 127.0.0.1] script not found or unable to stat: C:/Apache/Apache2.2/cgi-bin/first.pl

My hosts file (C:\WINDOWS\system32\drivers\etc) is currently:
127.0.0.1 localhost
127.0.0.1 http://www.malcolmhodgson.com
127.0.0.1 http://www.malcolmhodgson.com
127.0.0.1 malcolmhodgson.com
Originally it was just the first line.

Izzy wrote:Try this shebang:
#!"C:\Perl\bin\perl.exe"


Doh !!!!!!!

I've just used Perl Express instead of Notepad to save the PL script and it works !
For some reason Notepad originally saved the script as first.pl.pl which displays as first.pl in Explorer. :oops:
The double quotes on the shebang line weren't neccessary.
Notepad works with a different filename (fourth.pl), Save-As-Type All Files, Encoding ANSI.
Any mods can then be saved with just Ctrl-S.
Take me back to Linux please :!:

Thanks a lot Izzy and Nobbie, some great tips, your help was much appreciated.
u671296
 
Posts: 4
Joined: 22. November 2009 01:58

Re: script not found or unable to stat

Postby Nobbie » 24. November 2009 11:03

u671296 wrote:For some reason Notepad originally saved the script as first.pl.pl which displays as first.pl in Explorer. :oops:


Finally quite the same as my first hint. Notepad is well known for being a worse editor and saving files with additional extensions (in this case not *.txt but *.pl).

u671296 wrote:Take me back to Linux please :!:


Definately the best solution. But if you cannot switch back, you also may use "gvim for Windows", which is a fully functional windows version of the vi-editor of UNIX. Simply google for it.

Or go for "textpad" (www.textpad.com) also a really good editor, including syntax highlightning for many programming languages. I like this editor very much.
Nobbie
 
Posts: 6778
Joined: 09. March 2008 13:04


Return to Perl

Who is online

Users browsing this forum: No registered users and 1 guest