drujax has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl script that is supposed to create files for storing information if the user tries to create a new file. According to, "Learning Perl" if i use something like:
open(Filename, ">/home/httpd/cgi-bin/file");
file should be created because of the ">". However, this is not happening and the file is not created. Is this because technically the person using the script is Nobody? Thanks in advance for any light that can be shed on the subject

-dru

-newbie #260967645

Replies are listed 'Best First'.
Re: CGI doesn't make the file
by davorg (Chancellor) on Jul 27, 2000 at 20:34 UTC

    lhoward is quite right about the dangers of writing data files to the cgi-bin directory. Additionally, I'd like to point out that Perl will tell you why it's not writing the file if you ask it to:

    open(Filename, ">/home/httpd/cgi-bin/file") or die "Can't open file: $!\n";

    In a CGI environment, this error should be written to your web server's error log.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>
      Or if you add

      use CGI::Carp qw(fatalsToBrowser);

      You'll see them in the browser, very handy for debugging.

      --
      See you at Yapc::Europe!
      ... And then they asked me for a signature!

        Great for debugging, not so good for production servers as you run the risk of giving too much information to the bad guys.

        If you use fatalsToBrowser you should comment it out before putting the script into production.

        --
        <http://www.dave.org.uk>

        European Perl Conference - Sept 22/24 2000, ICA, London
        <http://www.yapc.org/Europe/>
RE: CGI doesn't make the file
by lhoward (Vicar) on Jul 27, 2000 at 20:29 UTC
    You should NEVER put data files in your cgi-bin directory. What you need to do is create a directory in an apropriate location on your server where the nobody user has apropriate permissions to create/write files.
Re: CGI doesn't make the file
by le (Friar) on Jul 27, 2000 at 20:32 UTC
Re: CGI doesn't make the file
by drujax (Initiate) on Jul 27, 2000 at 20:48 UTC
    hey guys, i got it figured out now, thanks for the help

    -drujax

    -newbie #260967645