Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Self Deletion

by andreychek (Parson)
on Jul 07, 2001 at 08:46 UTC ( #94691=note: print w/replies, xml ) Need Help??

in reply to Self Deletion

I have to admit -- I've never tried this particular task before, but I found it most amusing to build. Perhaps it was the danger that if I did it incorrectly I'd end up without my home directory or something like that :-)

However, I'm happy to announce that this code is tested, it does work, and I'll describe what it does so you know what you're getting yourself into :-)

#!/usr/bin/perl -w use File::Path; use File::Basename; # This extracts the path of the current directory into # the variable $dirname my $dirname = dirname($0); # The following line (beginning with the word "rmtree") is # commented for safety purposes. It WILL delete the # contents of the directory the script is in, and all it's # subdirs. I did test it, but please do not take my word # for it! Try it in your temp dir before putting this in # with your live data. # Uncommenting this line will cause files to be deleted! # rmtree([$dirname], 1, 1); print "This is a drill. If this were not a drill, the dir '$dirname', + and all of it's contents and subdirectories would be toast right now +.";
Update: Code has been removed until the original posted states why they want it.. while there are many legitimate reasons for this, there are also plenty of malicious ones.

Update 2: The original poster has posted a very legitimate reason for requiring this functionality. So without further ado, I have re-posted this code. I appologize for the delay, but unfortunatly not everyone is honest these days. Good luck!

Replies are listed 'Best First'.
Re^2: Self Deletion
by tadman (Prior) on Jul 07, 2001 at 12:16 UTC
    I believe, although I might be wrong, that this is for the purposes of developing an uninstaller, which has the inevitable consequence of deleting files including itself.

    This wasn't a suspicious request like:
    calculating criticle mass
    im trying calculate the critical mass of u235, does anyone have any sample code? Oh, does anyone know a quick way to compute yield? thanks!
    Just as knives could be used to hurt people, they are most often used for cooking or other peaceful and productive purposes.
      like andreychek said, there is no information as to what the intent is. Virus code was removed recently because it had the potential to become something that nobody wanted to be responsibl for. I don't think that most uninstallers go along deleting every file in a directory blindly, including itself. Why would you want to delete the uninstaller other then to rid the computer of the evidence as to what casued the deletion of the files. It looks a little suspecious to me. I'd like to see some reasoing behind the question, at least then some of the monks may be able to suggest a better way to do it. If it is for a ligit reason, the AM will have no problem following up and posting why they want to do this. It all comes down to the morality of posting potentially dangerous code on PM's.

      That's my story, and I'm sticking to it, unless I'm wrong in which case I will probably change it ;~)
      may be reproduced under the SDL
        Sure they do. A typical download will extract itself into a directory it creates off the TEMP directory, run it there, then delete it.
Re: Re: Self Deletion
by Anonymous Monk on Jul 09, 2001 at 01:51 UTC
    I am sorry I should have been more clean on the onset. I am using the script to put in directories of a very complex and automated classified lisitng system so that the listing will "delete itself" after a secified duration. This way i can have wierd and unique add durations such as 7.39 days or 60.33 minutes and so on.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://94691]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-03-30 22:54 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (364 votes). Check out past polls.