LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-24-2005, 07:11 AM   #1
burnham
LQ Newbie
 
Registered: Jul 2004
Posts: 11

Rep: Reputation: 0
Unable to delete files via php on Linux


Hello,

I have a script that unzips new files received on the linux server, processes the relevant files then deletes the unwanted ones. Unfortunately I can not delete the unwanted files.

I have checked the error log and found this:

replace {A3AACBC6-A493-4289-B041-4A33E114BA6C}.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(assuming [N]one)

I do not know what this means, so am stuck in figuring out any further. Any help would be really appreciated.

Thank you

Jay
 
Old 05-24-2005, 08:37 AM   #2
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Is it a PHP script that's processing and deleting the files? I generally write a shellscript when I want to do stuff like that and exec it from PHP.
 
Old 05-24-2005, 10:07 AM   #3
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
looks like the command you are using to replace the files is asking for confirmation before it will overwrite, but since it is a script i.e. not interactive, there is no-one to give any answer (y, n, A, N, or r), so it defaults to not overwriting. what command are you using to replace the files? there might be a switch/parameter that will force overwriting without asking for confirmation, which should fix that problem.

EDIT: hey cool, I'm not a newbie anymore - im a member!

Last edited by Ynot Irucrem; 05-24-2005 at 10:11 AM.
 
Old 05-25-2005, 06:21 AM   #4
burnham
LQ Newbie
 
Registered: Jul 2004
Posts: 11

Original Poster
Rep: Reputation: 0
It is a PHP script that's processing and deleting the files. The code in question is:
Code:
if(is_file($TXTfilename))
  {
   if(!unlink($TXTfilename))
     {
      logmessage("failed to delete $TXTfilename...<br>\n");
     }
  }
I have checked the php manual to see if unlink can take any parameters but unfortunately not.

Are you suggesting replacing this with:
Code:
$output = shell_exec('rm $filename');
Although doesn't rm prompt you with 'do you really want to delete' then you have to press 'y'?

Thank you

Jay
 
Old 05-26-2005, 09:31 AM   #5
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
I know a *little* php, but from the looks of that code, you obviously know much more.
you can use the "-f" swith to force rm to delete files. i.e.
Code:
$output = shell_exec('rm -f $filename');
 
Old 05-26-2005, 09:40 AM   #6
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally posted by Ynot Irucrem
I know a *little* php, but from the looks of that code, you obviously know much more.
Doesn't know too much more if he didn't know how to use a simple -f (force) option with the rm command.. Sorry, no pun intended, just consider yourself above him when it comes to shells rather than PHP..
 
Old 05-26-2005, 09:56 AM   #7
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
what i meant is he knows more php, not overall. o well.... free ego boost.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to delete files of MySQL laguna01 Red Hat 7 10-21-2005 05:51 AM
Unable to delete trash entropyv Mandriva 1 09-26-2004 12:29 PM
How to search and delete files in Unix/Linux puzz_1 Linux - General 5 04-09-2004 11:35 AM
PHP unable to read .php files tuka Linux - Software 6 10-12-2003 07:40 PM
Script on linux to delete certain files ForumKid Linux - General 2 06-22-2002 02:09 PM


All times are GMT -5. The time now is 10:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration