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,
> which I can't work out how to solve. I'm hoping someone can help me.
> 
> I have a very simple test case:
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> print "Content-type: text/html\n\n";
> print "<html><head></head><body>\n";
> open my $f, '>', 'test.txt' or print "$!\n";
> 
> 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.
> 
> The script has the permissions mask: '-rwxr-xr-x' and the directory has the
> permissions mask 'drwxr-xr-x'.
> 
> Myf White
> mailto:myfwh...@gmail.com
> 
> “Sometimes your joy is the source of your smile, but sometimes your smile
> can be the source of your joy." Thich Nhat Hanh
> 

The directory's permissions must be writable to create new files.
Apparently it is not to your web server.

It is considered a security breach to have the directory that contains
your CGIs writable.  Consider putting the files in a subdirectory not
accessible via the web.

Also, consider using CGI.pm  It is a standard module that comes with
Perl.  See `perldoc CGI` or http://perldoc.perl.org/CGI.html


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to