in reply to creating a file with a cgi script

I'd guess that the web server user doesn't have rights to write to that directory. You don't seem to be doing any kind of error checking.

And that's not a very portable or efficient way to write to a file. Why not use "open", "flock" and "print"?

Two other small points. Firstly, writing log files in your cgi-bin isn't a very good idea. Depending on how your web server is configured, it's possible that the server will try to execute them when they are requested by a browser. Secondly, I'm not sure what is in you $par2 variable, but the syntax of your "cat" call doesn't look right.

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

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: creating a file with a cgi script
by Anonymous Monk on May 19, 2006 at 08:15 UTC
    Hi davorg,
    Following your advice I tried this
    my $OUTFILE_file_name = "../user_log/".$req_id."\.txt"; open ( OUTFILE, '>', $OUTFILE_file_name ) or die "$0 : failed to open output file $OUTFILE_file_name : $ +!\n"; print OUTFILE $uemail; close ( OUTFILE ); # close output file
    But it still doesn't get printed in user_log/
    And I also get this message
    failed to open output file ../user_log/22410.txt : Permission denied
    What's wrong with it?

      As I said before, your web server process doesn't have permission to write to that directory. The error message seems pretty clear to me, but if you want more detail then try adding "use diagnostics" to your program.

      Which user does your web server run as? Do you use suexec at at? What are the permissions on the directory that you are trying to write to?

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

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        I'm not an SU. And the permission looks like:
        drwxr-xrw- 2 myname myname 4096 May 19 15:28 user_log

      You're trying to write in your ${HOME}, but as apache is running as a specific user (www or apache), it can't perform the operation, as it doesn't have the proper permissions for doing that.

      Igor 'izut' Sutton
      your code, your rules.