Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete files via CGI on Win2k/IIS5 1

Status
Not open for further replies.

Arion23

IS-IT--Management
Mar 29, 2001
132
AU
Hi all,

I have a script that generates temporary files into a directory on the server called "/files" (c:\inetpub\
Part of my script is to go through this directory and delete any files older than a certain time period. This is the code I have:

foreach $file (<c:/inetpub/ {
# if((-C $file) >= 0.1) {
system(&quot;del $file&quot;); }
#}

I've commented out the two lines because, for testing, I want to see if I can deleted all files in this directory.

The NTFS permissions for this dir have been set to Full Control for Everyone (again for testing), likewise with IIS's permissions - but it still don't work!

Can anyone offer any advice (or alternate code) as to how I might do this...

Thanks in advance
 
Hey there,

I have done most of my CGI programming on NT (IIS5), but i haven't had the need to delete any files yet.

Elsewhere (as a stand alone app on my NT machine), I used
unlink to delete files...it is thorough and it seemed to get the job done....

I just tested it on my IIS and the following works ok.


use CGI qw(all:)
$startpath = 'C:/inetpub/$nasty = &quot;test.txt&quot;;
sub doit {
$nasties = $startpath . $nasty;
unlink $nasties or warn &quot;Can't delete $nasties: $!\n&quot;;
}
sub other {
print header;
print &quot;<html><head><title></title></head><body>&quot;;
print &quot;Done!!</body></html>&quot;;
}

&doit();
&other();
exit(0);

Hope this helps, oh and the web server is set to run scripts (but not scripts and executables).


Jez
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top