|
I have very little experience of Perl! I have been trying to delete a file using a script and it is refusing to go. One script creates the temporary file (empty) and later another is to delete it.
The url passes a parameter to the script: e.g. dfile.pl?f=abcde
The filename f obviously varies.
In the script:
$thef=param('f');
$ful="../../alpha/tempf/".$thef;
unlink($ful);
refuses to delete the file (e.g. abcde). When I manually enter:
unlink("../../alpha/tempf/abcde"); it goes. (It has nothing to do with file permissions).
Also I can test if the file exists, using the variable, -e $fnmi and I get true.
I would be very grateful if someone could suggest what the problem is here!
|
|
|
make sure that $thef and $ful contain what they are supposed to contain.
either with a debugger or simply by changing the script to the following:
$thef=param('f');
$ful="../../alpha/tempf/".$thef;
print STDOUT "The filename was: $thef\n";
print STDOUT "The full path was: $ful\n";
unlink($ful);
I also recommend using more descriptive and clear names like, $filename and $path and $path_and_file.
|
|
|
Thanks, yes everything was as it was supposed to be in the strings. I had narrowed it down to simply the use of the parameter. I have since learned how to read the error log on the server(!) and it told me the problem. I had a -T switch in the script. Apparently this is 'taint mode' and it realised that a parameter from outside was being used to delete a file and it disallowed it. The quick fix was to remove the -T switch, but now I'm playing around with regular expressions to try to validate the parameter and hopefully I'll be able to restore the -T switch.
Thanks again.
|
|
|
|
|
|
|
// |