in reply to File protection in a called script

"will not work" is not very specific. Is the file being created but is empty? Is it not getting created at all? What error messages are you getting? (If none, you should add some diagnostic messages.)

However, I'm going to guess that you're trying to write into the directory where the CGI is executing, and you don't have permission to do that. Try putting in an absolute path for the file name: $file = '/tmp/current.txt'; #or some suchRemember, the directory that the file is in is not necessarily the current directory when it executes.

HTH

Replies are listed 'Best First'.
Re: Re: File protection in a called script
by TrinityInfinity (Scribe) on Nov 15, 2002 at 16:45 UTC
    "My bad" sums it up nicely, I didn't write specifically what was going wrong.

    In the subscript - it doesn't appear to write to the file. I've set a variable to trap the returned value of the Open statement, and it opens the file allright! But when I've tried to read lines out of that file (@lines = <FILE>, or while <FILE> print $_), nothing prints. Nothing is written. It's a mystery to me.

    I also tried at this same point in the script to simply copy the file to another, using system(`cp file1 file2`) as well as regular backticks. In both cases, the created file is size 0! But as I said above, all these tricks I've tried in a standalone script, which runs fine. Bizarre!
      What does the file contain after the script is finished running? What happens when you run the script from the command-line passing the same arguments? Also, you might want to check the return values of the print and close calls. Those can sometimes fail (although usually not for files) especially if the disk is full.