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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-24-2005, 06:11 AM
|
#1
|
LQ Newbie
Registered: Jul 2004
Posts: 11
Rep:
|
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
|
|
|
05-24-2005, 07:37 AM
|
#2
|
Member
Registered: May 2005
Posts: 378
Rep:
|
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.
|
|
|
05-24-2005, 09:07 AM
|
#3
|
Member
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233
Rep:
|
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 09:11 AM.
|
|
|
05-25-2005, 05:21 AM
|
#4
|
LQ Newbie
Registered: Jul 2004
Posts: 11
Original Poster
Rep:
|
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
|
|
|
05-26-2005, 08:31 AM
|
#5
|
Member
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233
Rep:
|
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');
|
|
|
05-26-2005, 08:40 AM
|
#6
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
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.. 
|
|
|
05-26-2005, 08:56 AM
|
#7
|
Member
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233
Rep:
|
what i meant is he knows more php, not overall. o well.... free ego boost.
|
|
|
All times are GMT -5. The time now is 02:43 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|