473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 3830
numberwhun
3,509 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,509 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,509 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

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

Similar topics

2
by: Eric | last post by:
Hello, I created a form to upload files. The formfield contents are stored as records in an Ascii file "data.dat"; for reasons I am not using a MySql database. The upoaded file itself is stored...
4
by: lawrence | last post by:
I wrote some code that let me upload a file to my server. Then I wrote some code to let me delete the file. But when I try to delete, I get this error: Warning: Unlink failed (Permission denied)...
5
by: Phil Powell | last post by:
print_r(is_file("$logPath/$logFileName")); // RETURNS 1 unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED This code should tell me that the file located at...
4
by: rbt | last post by:
Can someone detail the differences between these two? On Windows which is preferred? Also, is it true that win32api.DeleteFile() can remove the 'special' files located in the 'special' folders...
6
by: Benjamin | last post by:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try to unlink I get this: "Warning: unlink(file.txt) : Permission denied..." What and how do I change this so it works? Thanks
4
by: nitinpatel1117 | last post by:
Hi I am trying to delete a csv file using the unlink() function, but i keep getting a permission denied warning Warning: unlink(UsedNOS200704191.CSV): Permission denied in...
15
by: Morteneistrom | last post by:
Im a complete n00b at PHP so please forgive me if this i a stupid question Why wont the following work. PHP Code: <?php foreach (glob('../images/profil/*.jpg') as $filename) { echo...
11
by: byteoart | last post by:
I'm a newbie to php. I am trying to delete a file from the server that I put there (one file, not the whole directory). I am using unlink ($filename); I did the path as a relative path as...
18
by: Coffee Pot | last post by:
Thanks for any advice. ~ CP
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.