469,267 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

unlink will not delete

I have been trying to delete a file using a script and it is refusing to go. (I have very little experience of Perl). 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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. $thef=param('f');
  3. $ful="../../alpha/tempf/".$thef;
  4. unlink($ful);
  5.  
  6.  
it 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!
Dec 7 '07 #1
7 3451
numberwhun
3,503 Expert Mod 2GB
I have been trying to delete a file using a script and it is refusing to go. (I have very little experience of Perl). 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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. $thef=param('f');
  3. $ful="../../alpha/tempf/".$thef;
  4. unlink($ful);
  5.  
  6.  
it 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!
Try using the absolute path instead of "../.." before the file name and see if that works.

Regards,

Jeff
Dec 7 '07 #2
Thanks - tried that, but no good.
Dec 7 '07 #3
KevinADC
4,059 Expert 2GB
hmmm, same q on at least three forums. See tek-tips for my suggestion.
Dec 7 '07 #4
Thanks! Solved - I simply needed to remove the -T switch at the top of the perl script.
Dec 7 '07 #5
numberwhun
3,503 Expert Mod 2GB
Thanks! Solved - I simply needed to remove the -T switch at the top of the perl script.
You know, there is a REASON that we normally request the whole code. That way, we can see things like that!
Dec 8 '07 #6
Yes, that would have saved some time! But I learned to read error logs on the server(!) - very useful.
Dec 8 '07 #7
numberwhun
3,503 Expert Mod 2GB
Yes, that would have saved some time! But I learned to read error logs on the server(!) - very useful.
No problem, glad that you fixed it!
Dec 8 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Eric | last post: by
4 posts views Thread by rbt | last post: by
6 posts views Thread by Benjamin | last post: by
4 posts views Thread by nitinpatel1117 | last post: by
15 posts views Thread by Morteneistrom | last post: by
11 posts views Thread by byteoart | last post: by
18 posts views Thread by Coffee Pot | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.