Can't remove directory

Discussion in 'Perl Misc' started by Slickuser, Aug 25, 2008.

  1. Slickuser

    Slickuser Guest

    I use SVN to checkout a folder and SVN set the directory to read only.

    Using File::path module, rmtree($path) to try do delete all files &
    directories in that folder.
    I get error: Can't remove directory

    Is there some way I can remove it. I try looking at chmod but doesn't
    help it either. Thanks.

    my $dir_del = "C:\folderA\ABC\D\E";
    $dir_del =~ s/\\/\//ig;
    chmod($dir_del,0755);
    rmtree($dir_del);
    Slickuser, Aug 25, 2008
    #1
    1. Advertising

  2. Slickuser <> writes:

    > my $dir_del = "C:\folderA\ABC\D\E";


    Those backslashes aren't doing what you think they're doing:

    localhost:~ sherm$ cat testme.pl
    #!/usr/bin/perl

    use warnings;
    use strict;

    my $dir_del = "C:\folderA\ABC\D\E";
    print $dir_del, "\n";

    localhost:~ sherm$ perl testme.pl
    Unrecognized escape \A passed through at testme.pl line 6.
    Unrecognized escape \D passed through at testme.pl line 6.
    C:
    olderAABCD
    localhost:~ sherm$


    You should just use forward slashes, which work just fine on Windows,
    and don't mean anything special in double-quoted strings.

    It's a good idea enable both strict and warnings, and pay attention to
    messages such as the warnings shown above. It's also a good idea to
    include the filename in any error messages you print, along with $!,
    to help alert you when a filename you're using isn't really what you
    think it is.

    sherm--

    --
    My blog: http://shermspace.blogspot.com
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Sherm Pendley, Aug 25, 2008
    #2
    1. Advertising

  3. Slickuser <> wrote:
    >I use SVN to checkout a folder and SVN set the directory to read only.
    >
    >Using File::path module, rmtree($path) to try do delete all files &
    >directories in that folder.
    >I get error: Can't remove directory
    >
    >Is there some way I can remove it. I try looking at chmod but doesn't
    >help it either. Thanks.
    >
    >my $dir_del = "C:\folderA\ABC\D\E";


    Are you sure you got a directory named

    C:<formfeed>olderAABCDE

    See "perldoc -q DOS"
    Why can't I use "C:\temp\foo" in DOS paths?
    What doesn't `C:\temp\foo.exe` work?
    for details.

    jue
    Jürgen Exner, Aug 25, 2008
    #3
  4. Slickuser <> wrote:


    > I try looking at chmod



    > chmod($dir_del,0755);



    Did you look as far as the 2nd sentence in the docs for chmod?

    ... The first element of the list must be the numerical mode


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Aug 26, 2008
    #4
  5. Slickuser

    Slickuser Guest

    Sorry, it was \\. I try all possible case with directory structure,
    still doesn't work. Even with C:/folderA/..

    Those folders do exist. I can delete it manually. It just ask me to
    remove all files. I have to confirm ALL to remove it.

    my $dir_del = "C:\\folderA\\ABC\\D\\E";
    #$dir_del = 'C:\folderA\ABC\D\E';
    $dir_del =~ s/\\/\//ig;
    chmod($dir_del,0755);
    rmtree($dir_del);
    Slickuser, Aug 26, 2008
    #5
  6. Slickuser

    J. Gleixner Guest

    Slickuser wrote:
    > Sorry, it was \\. I try all possible case with directory structure,
    > still doesn't work. Even with C:/folderA/..
    >
    > Those folders do exist. I can delete it manually. It just ask me to
    > remove all files. I have to confirm ALL to remove it.
    >
    > my $dir_del = "C:\\folderA\\ABC\\D\\E";
    > #$dir_del = 'C:\folderA\ABC\D\E';
    > $dir_del =~ s/\\/\//ig;


    Yuck.

    my $dir_del = 'C:/folderA/ABC/D/E';

    > chmod($dir_del,0755);


    Wrong order of arguments.

    perldoc -f chmod

    Have chmod tell you when it fails and why:
    chmod( ..., ... ) or die "chmod failed: $!"

    > rmtree($dir_del);


    Once you correct chmod, read the documentation for rmtree again
    for options on how to get more verbose output so you can see what it
    is/isn't deleting.
    J. Gleixner, Aug 26, 2008
    #6
  7. Slickuser <> wrote:

    > Sorry,



    Sorry for what?

    Please quote some context in your followups like everybody else does.


    > it was \\.



    What was \\?


    > $dir_del =~ s/\\/\//ig;



    Are you saying that \\ was supposed to be in the regex there?

    Why are you saying it in a followup to my post, where there
    was no regex at all?


    > chmod($dir_del,0755);



    Repetition is the key to learning so,

    Did you look as far as the 2nd sentence in the docs for chmod?

    ... The first element of the list must be the numerical mode

    Are you paying any attention to the followups you've been getting?

    It sure doesn't look like it.

    There is not much point in trying to help you if you are
    not going to accept any help.

    So long!


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Aug 26, 2008
    #7
  8. Slickuser

    Slickuser Guest

    Error:
    Dir exist.
    chmod failed: No such file or directory at C:\script\chmod2.pl line
    123.


    $source = "c:/abc/a";
    if (-d $source)
    {
    print "Dir exist.\n";
    chmod($source,0644) or die "chmod failed: $!"; #line 123 here
    }




    On Aug 26, 3:32 pm, "J. Gleixner" <>
    wrote:
    > Slickuser wrote:
    > > Sorry, it was \\. I try all possible case with directory structure,
    > > still doesn't work. Even with C:/folderA/..

    >
    > > Those folders do exist. I can delete it manually. It just ask me to
    > > remove all files. I have to confirm ALL to remove it.

    >
    > > my $dir_del = "C:\\folderA\\ABC\\D\\E";
    > > #$dir_del = 'C:\folderA\ABC\D\E';
    > > $dir_del =~ s/\\/\//ig;

    >
    > Yuck.
    >
    > my $dir_del = 'C:/folderA/ABC/D/E';
    >
    > > chmod($dir_del,0755);

    >
    > Wrong order of arguments.
    >
    > perldoc -f chmod
    >
    > Have chmod tell you when it fails and why:
    >         chmod( ..., ... ) or die "chmod failed: $!"
    >
    > > rmtree($dir_del);

    >
    > Once you correct chmod, read the documentation for rmtree again
    > for options on how to get more verbose output so you can see what it
    > is/isn't deleting.
    Slickuser, Aug 27, 2008
    #8
  9. Slickuser <> wrote in news:f58abccd-f5af-43e1-a2c3-
    :

    > $source = "c:/abc/a";
    > if (-d $source)
    > {
    > print "Dir exist.\n";
    > chmod($source,0644) or die "chmod failed: $!"; #line 123 here
    > }
    >


    This is the third time you have been told this:

    perldoc -f chmod

    chmod LIST
    Changes the permissions of a list of files. The first element
    of the list must be the numerical mode

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://www.rehabitation.com/clpmisc/
    A. Sinan Unur, Aug 27, 2008
    #9
  10. Slickuser <> wrote:

    > chmod failed: No such file or directory at C:\script\chmod2.pl line

    ^^^^^^^^^^^^^^^^^^^
    >
    >
    > $source = "c:/abc/a";

    ^^^^^^^^
    > {
    > print "Dir exist.\n";
    > chmod($source,0644) or die "chmod failed: $!"; #line 123 here
    > }



    That output clearly did not come from that program.

    If you compare the output of one program with the code of a different
    program, you will never solve your problem.

    If you need help with your program, then we will need to
    see *the same program" that you are running!


    [ snip upside-down posting.
    Please do not top-post.
    Quote, snip and interleave comments like everybody else does.
    ]

    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Aug 27, 2008
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon-Pierre  Jarry
    Replies:
    2
    Views:
    2,344
    Henrik
    Aug 10, 2005
  2. kbass
    Replies:
    2
    Views:
    1,758
    Graham Fawcett
    Nov 13, 2003
  3. Replies:
    0
    Views:
    282
  4. tshad
    Replies:
    6
    Views:
    21,435
    tshad
    Aug 8, 2006
  5. Peng Yu
    Replies:
    0
    Views:
    321
    Peng Yu
    Nov 6, 2009
Loading...

Share This Page