Myf White wrote:
I've never done much in the way of cgi scripts before, and am just getting
started with it. I have encountered what seems to be a permissions problem,
...
When I run this script on the server: > test.cgi, the test.txt file is
created. However when I use a browser as a client to execute the script, it
prints the $! OS_ERROR "Permission denied" and the test.txt file is not
created.
A key concept is that web servers typically run under a dedicated
username/ UID. For example, on Debian 5.0.3:
2009-10-10 11:05:31 dpchr...@p43400e ~
$ grep www-data /etc/passwd
www-data:x:33:33:www-data:/var/www:/bin/sh
If you don't care about security, you could grant world-write access to
your cgi-bin directory. If you have root access, another option could
be to configure the web server to run as your login UID.
If you do care about security, things get more complicated. If you just
want a simple test case to verify that you can run CGI scripts, a
"hello, world!" Perl/ CGI script follows FWIW.
HTH,
David
--
2009-10-10 11:19:55 dpchr...@p3450 ~
$ cat cgi-hello/cgi-hello.cgi
#! /usr/bin/perl -T
#######################################################################
# $Id: cgi-hello.cgi,v 1.8 2006-11-18 02:37:24 dpchrist Exp $
#
# CGI "hello, world!".
#
# Copyright 2005 by David Paul Christensen <dpchr...@holgerdanske.com>
#
# This software is released under the Perl Artistic License.
#######################################################################
# uses:
#----------------------------------------------------------------------
use warnings;
use strict;
#######################################################################
# script:
#----------------------------------------------------------------------
print <<END;
Content-type: text/html
<HTML>
<HEAD>
</HEAD>
<BODY>
hello, world!
</BODY>
</HTML>
END
#######################################################################
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/