Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
CGItemp files

Posted by TedH (TedH), 5 October 2005
In writing a Perl based CMS, I've run across a weird thing that happens when a file is uploaded. My script can add, edit and delete the text based files nice as you please. If an image is needed I can upload to the correct folder in the webspace fine.

However, on a Windows based machine a file named CGItemp***** (***** = random number) is created in the same folder as the upload script and left there. The CGItemp file is the same size as the image that was uploaded - so I understand why it's there.

Now on Apache/Unix (evidently), this gets deleted immediately - but not on a Windows server.

This seems to be a common problem and the replies I've seen say takes cares of - no it does not. Only by FTP'ing in and manually delete does it go.

I've got a feeling that there must be some way to unlink any file in that folder that begins with CGItemp, but don't know it.

Any suggestions?

cheers - Ted

Posted by admin (Graham Ellis), 5 October 2005
Here's an example that deletes all files that match a particular pattern in a particular directory.   I've printed out the names and NOT deleted them in this test code - just uncomment the unlink line to make it work.

$dirname = "/Library/WebServer/cgi-bin";
opendir (DH,$dirname);
@getrid = map("$dirname/$_",grep(/\.tgz$/i,readdir DH));
# unlink @getrid;
print "@getrid\n";

To change to CGItemp files, replace the \.tgz$ regular expression with ^CGItemp.   I have used the "i" (ignore case) modifier because you're talking Windows in the question ....

Posted by TedH (TedH), 6 October 2005
Thanks Graham, that works very nicely.

Now I can have an option for Windows users so the temporary files can be purged.

Did you ever get the directory done that you mentioned?

cheers - Ted

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho