How can I delete files useing Perl

M

moneytea

Hi,
I am a newbie,I try to use this programs to delete files(OS is Linux)
----------------------------------------
# file DEL.pl
#!/usr/bin/perl
$readparse;
print "Content-type: text/html\n\n";
unlink "del_file";
----------------------------------------
I can execute this program in command line ( ./DEL.pl) then it works .and
the file "del_file"
was removed ,but when I put "DEL.pl" into the /usr/local/apache/cgi-bin/ ,It
do nothing.
I really do not understand.
I even try this : system ("rm -rf del_file") ,not work too!
this program has the popedom of root.
Can anyone help me ?
thanks
 
T

Tintin

moneytea said:
Hi,
I am a newbie,I try to use this programs to delete files(OS is Linux)
----------------------------------------
# file DEL.pl
#!/usr/bin/perl
$readparse;
print "Content-type: text/html\n\n";
unlink "del_file";
----------------------------------------
I can execute this program in command line ( ./DEL.pl) then it works .and
the file "del_file"
was removed ,but when I put "DEL.pl" into the /usr/local/apache/cgi-bin/ ,It
do nothing.

Oh but it will do something if you inspect the reason it "do nothing", ie:

unlink "del_file" or die "Could not delete del_file because $!\n";

and I'm willing to say with 99% certainity that the reason will be "No such
file or directory"
 
J

Jürgen Exner

moneytea wrote:
[...]
I can execute this program in command line ( ./DEL.pl) then it works
.and the file "del_file"
was removed ,but when I put "DEL.pl" into the
/usr/local/apache/cgi-bin/ ,It do nothing.
I really do not understand.
I even try this : system ("rm -rf del_file") ,not work too!
this program has the popedom of root.
Can anyone help me ?

Please see "perldoc -q 500".
Although that FAQ seems to answer a different question, the answer applies
in your case, too.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top