Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Removing Directory and Contents with Perl

by ptum (Priest)
on Mar 01, 2007 at 22:31 UTC ( #602797=note: print w/replies, xml ) Need Help??

in reply to Removing Directory and Contents with Perl

Perhaps what you want, for at least some unix variants, is something like this:

#!/usr/local/bin/perl -w use strict; my $deletedir = '/tmp/test1'; my $result = system("rm -rf $deletedir"); print "Result: $result\n";

Replies are listed 'Best First'.
Re^2: Removing Directory and Contents with Perl
by shandor (Monk) on Mar 02, 2007 at 02:35 UTC

    I would put some strict testing around an "rm -rf" command, especially if you're running this script as root/Admin. We recently lost several TB of data because a script didn't set the directory variables correctly and ran "rm -rf /*" (instead of "rm -rf $path_to_home/*") as root.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://602797]
[marto]: ah Sun, I sold my Pizzabox in around 2005
[Corion]: I used one at $work as a terminal, but those days are long gone by ;)
[marto]: I have an old IBM infowindow terminal to repurpose, I'll just wire a raspberry piz zero to the cable, providing access and wiFi :P
[marto]: the kids will love it
[Corion]: marto: Hehe ;) I've been toying with the idea of soldering an USB (-C) hub into a keyboard and making it a computer by slotting my phone into that :)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2018-03-21 11:24 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.