LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   delete file php linux (https://www.linuxquestions.org/questions/linux-newbie-8/delete-file-php-linux-877538/)

athrin 04-28-2011 01:49 AM

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

brownie_cookie 04-28-2011 01:52 AM

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

athrin 04-28-2011 01:54 AM

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

brownie_cookie 04-28-2011 01:58 AM

are those folders accessible?

athrin 04-28-2011 02:00 AM

Quote:

Originally Posted by brownie_cookie (Post 4338921)
are those folders accessible?

err... maybe...

brownie_cookie 04-28-2011 02:03 AM

check that pls ;)
normally it should

have you made your scripts executable?
Code:

chmod 755 delete.sh

athrin 04-28-2011 02:05 AM

Quote:

Originally Posted by brownie_cookie (Post 4338928)
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

brownie_cookie 04-28-2011 02:09 AM

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

athrin 04-28-2011 02:12 AM

yup.. its accessible.
Quote:

-rwxr-xr-x 1 root root 359 Apr 27 16:19 delete.sh

brownie_cookie 04-28-2011 02:22 AM

have you tried this

are you working on a Linux system or on a Windows system and working through PuTTy (or something else)

athrin 04-28-2011 02:41 AM

Quote:

Originally Posted by brownie_cookie (Post 4338943)
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..

brownie_cookie 04-28-2011 02:42 AM

okay, but have you tried that link i showed you?

athrin 04-28-2011 02:48 AM

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..

brownie_cookie 04-28-2011 02:57 AM

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...)

athrin 04-28-2011 03:00 AM

Quote:

Originally Posted by brownie_cookie (Post 4338982)
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?


All times are GMT -5. The time now is 04:22 PM.