Writing to a file problems..
Posted on 1998-06-22
OK, I wrote this program which needs to write out to a file, and it worked initially. But for some reason, it won't
work now. I didn't change the file at all, and it just stopped writing to the file. It was still running and doing everything correctly, except opening a file for writing.
I've tried several things, and wrote a simplified version for easier testing, and found that my server wasn't allowing the script to open a file for writing when called from a web page (a form submission), but it worked fine when
I ran it from the command line.
The files have 775 permissions. Any ideas? Here's the test script I wrote:
# print the header to start the output page
print "Content-type: text/html\n\n";
open(IN, "week-3-7--3-13.txt"); # Open the file
@lines = <IN>; # Read it into an array
close(IN); # Close the file
open(OUT, ">newfile.txt"); # Open the file
print OUT "@lines"; # Write updated scores to the file
close(OUT); # Close the file