Can't remove directory

S

Slickuser

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);
 
S

Sherm Pendley

Slickuser said:
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--
 
J

Jürgen Exner

Slickuser said:
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
 
T

Tad J McClellan

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
 
S

Slickuser

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);
 
J

J. Gleixner

Slickuser said:
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.
 
T

Tad J McClellan

Slickuser said:


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!
 
S

Slickuser

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
}
 
A

A. Sinan Unur

$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 <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 
T

Tad J McClellan

Slickuser said:
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.
]
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,050
Members
48,769
Latest member
Clifft

Latest Threads

Top