Re: cannot open and write file

From: A. Sinan Unur (1usa_at_llenroc.ude.invalid)
Date: 01/21/05


Date: 21 Jan 2005 04:37:46 GMT


"Roll" <lie_huo@hotmail.com> wrote in
news:5b06d7c84f17e758419955dab21b8b78
@localhost.talkaboutprogramming.com:

> i want to try writing to a file. i try this coding
> <write.cgi>
> #!/usr/bin/perl
> open(OUTF,">>/root/a.conf");
> print OUTF "anc";
> close OUTF
>
> but when i open this page using a web browser, it give me an error
> 403?? can anyone tell me y is this so did i miss some coding or it
> should be written in another way?

The fact that you get a 403 status code means your script did not even
run (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).

Even then, your script does not seem to be a CGI script. Try the
following:

#! /usr/bin/perl

use strict;
use warnings;

use CGI;

print header,
      start_html,
      p('Hello World'),
      end_html;

__END__

To see if you have set up your web server correctly.

I find that highly unlikely given that you seem to want to give the
whole wide world write access to root's home directory.

Note that your question at this point is not really a Perl question.
Questions that are solely about CGI your web server set up should be
directed to the relevant fora.

You may also benefit from reading:

perldoc -q 500

Sinan.



Relevant Pages

  • Re: Can CGI script un-virtualize a relative path?
    ... > the physical paths are to the CGI script rather than the web page. ... located in respective home directory, ...
    (comp.lang.tcl)
  • Re: strange problem..program not working through web form.
    ... > But the problem is that when I run the script from the commandline it ... who is used to run CGI programs on your web ... have permission to execute cat and /bin/mail? ... What about "it works fine when using the UID of the web server"? ...
    (comp.lang.perl)
  • Re: Calling a perl script from an html doc
    ... The CGI specification (which in general is off-topic for discussion on ... script") and a web server. ...
    (comp.lang.perl.misc)
  • Re: Error in using GD Image
    ... Note that the probable reason for this is that when your web server runs your CGI script, your script's current directory isn't set to where you seem to think it is. ... Note also that the user the script is running under may also not be who you think it is, and that that can cause permissions problems. ...
    (comp.lang.perl.misc)
  • Re: displaying output of a text file in html
    ... You have to configure your web server to support .pl as cgi application. ... Brainbench MVP for HTML ... > I want to call this script within my webpage. ...
    (microsoft.public.inetsdk.html_authoring)