LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-28-2011, 02:49 AM   #1
athrin
Member
 
Registered: Mar 2011
Posts: 135

Rep: Reputation: 1
delete file php linux


hi,

i wanna ask on how to delete a file or a certain file in linux by using php or in other word by using web browser.
example i want to delete the file inside /var/www/cgi-bin/ with browser.
thank you.

Kind regards,
Athrin
 
Old 04-28-2011, 02:52 AM   #2
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
the remove command in linux is

Code:
rm -f /var/www/cgi-bin/somefile
the parameter -f is a forced remove, so he wont ask that you are sure for deleting that file
if you do want that he asks you that, just leave it out

but for deleting a file through a website...? don't know, try experimenting with that
 
Old 04-28-2011, 02:54 AM   #3
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
i already experiment with
Code:
1.system('rm -f /var/www/cgi-bin/delete.sh')
2.shell_exec('rm -rf /var/www/cgi-bin/delete.sh');
not working

Last edited by athrin; 04-28-2011 at 02:58 AM.
 
Old 04-28-2011, 02:58 AM   #4
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
are those folders accessible?
 
Old 04-28-2011, 03:00 AM   #5
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
are those folders accessible?
err... maybe...
 
Old 04-28-2011, 03:03 AM   #6
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
check that pls
normally it should

have you made your scripts executable?
Code:
chmod 755 delete.sh
 
Old 04-28-2011, 03:05 AM   #7
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
check that pls
normally it should

have you made your scripts executable?
Code:
chmod 755 delete.sh
oh you mean delete.sh color turn into green right? if so.. its already executable
 
Old 04-28-2011, 03:09 AM   #8
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
euhm.. yes, but you can also check it with
Code:
ls -l
and this should be in front of your script
Code:
-rwxr-xr-x   1 root root  7422 Apr 28 07:44 delete.sh
but that should be fine.

but i also mean if the folders are accessible


I don't think that are the problems, but it's worth checking
 
Old 04-28-2011, 03:12 AM   #9
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
yup.. its accessible.
Quote:
-rwxr-xr-x 1 root root 359 Apr 27 16:19 delete.sh
 
Old 04-28-2011, 03:22 AM   #10
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
have you tried this

are you working on a Linux system or on a Windows system and working through PuTTy (or something else)
 
Old 04-28-2011, 03:41 AM   #11
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
have you tried this

are you working on a Linux system or on a Windows system and working through PuTTy (or something else)
yup.. i'm working through PuTTy..
 
Old 04-28-2011, 03:42 AM   #12
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
okay, but have you tried that link i showed you?
 
Old 04-28-2011, 03:48 AM   #13
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
when i tried this from the link that you just give
Code:
$myFile = "delete.sh";
$fh = fopen($myFile, 'w') or die("can't open file");
fclose($fh);
output: can't open file

that mean my file cant be opened.. =_=. then ofcourse cant use unlink..

Last edited by athrin; 04-28-2011 at 03:52 AM.
 
Old 04-28-2011, 03:57 AM   #14
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
try to run your file on your host (not through your website)
and put some echo's or things in your script that shows you where he get stuck
(debug it...)
 
Old 04-28-2011, 04:00 AM   #15
athrin
Member
 
Registered: Mar 2011
Posts: 135

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by brownie_cookie View Post
try to run your file on your host (not through your website)
and put some echo's or things in your script that shows you where he get stuck
(debug it...)
you mean just run like this?
Quote:
php regen.php
or run something else like a new script?

Last edited by athrin; 04-28-2011 at 04:05 AM.
 
  


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
trying to delete data from a file with php steve51184 Linux - Server 5 04-28-2011 03:20 AM
How to delete a file with this syntax: index.php\n Procher Linux - Newbie 4 11-07-2009 02:24 PM
delete temp file in linux Arjun123 Linux - Newbie 2 06-24-2009 01:18 AM
Unable to delete files via php on Linux burnham Linux - Newbie 6 05-26-2005 09:56 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 03:46 AM


All times are GMT -5. The time now is 02:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration