I'm a little rusty in my Perl, forgive me if this is an obvious question :-/
I'm having an issue with one script where files are disappearing during processing, and I can't find exactly why. So I want to copy the files to a backup at the very beginning of the script, just in case.
I wrote a test script:
# test.cgi
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use File::Copy;
if (-e "/home/example/data/copy.txt") {
copy("/home/example/data/copy.txt","/home/example/data/copy2.dat") or die "Copy failed: $!";
}
print "Done";
exit;
and it throws the following error:
Copy failed: Permission denied at blah blah blah The /home/example/data directory is set to 0755, and copy.txt is 0777. Both test.cgi and copy.txt are owned by root root.
I originally tried it with copy.txt in the cgi-bin with test.cgi and had the same error, so I moved it to /data/ where other files (all 0777) are regularly modified and updated with no problem. So the issue shouldn't be the directory, at least.
Any suggestions?