markguy has asked for the wisdom of the Perl Monks concerning the following question:

while hdp and converter struggle to help me on chatterbox, I thought I'd ask this just in case we can't find a solution.

I have a script that needs to create a series of directories. I hand wrote something that would walk the path, creating each directory (if needed) and have also tried using File::Path's functions. both work fine, right up until I try to create this directory: '/blah/10'.

At this point, both mkdir and File::Path::mkpath die with $! set to "file exsists", etc. and sure enough, there's a file sitting there so that '/blah/10' would test successfully against -e, not -d. it's ~185K, filled with a bunch of hex and isn't there immediately before the mkdir executed (I've tested... rm -rf'd the entire directory beforehand as well).

'/blah/09' and '/blah/11' are made with no trouble prior to '/blah/10'. this is running on a solaris box. 'mkdir 10' from the command line works fine.

Anyone? Bueller? :)

Replies are listed 'Best First'.
Re: freaky mkdir problem
by dws (Chancellor) on Apr 26, 2001 at 23:13 UTC
    It really, really helps to post a code fragment that demonstrates the problem. The challenge with trying to describe what you're doing is that if you have blind spots, they carry over into your description. With code, we have something objective to analyze.

    Without code to look at, I can't tell from your description whether you're trying   mkdir("/blah/10", 0nnn) or die "/blah/10: $!"; or

    chdir("/blah") or die "/blah: $!"; mkdir("10", 0nnn) or die "10: $!";
    One of these is fundamentally wrong. The other should work, or should tell you why it isn't working.

      the first. and the second. and File::Path's:
      mkpath( '/blah/10' , 0 , 0775 ) or die "$!";
      they all return the same error, which I mentioned in the original post. the issue isn't how I'm implementing the mkdir, it's the fact the mkdir is creating a file instead of a directory.
      personally, I'm at a loss to see how any implementation of mkdir can explain what I'm seeing. which, of course, might explain why I'm here in the first place.
        Very odd. Perhaps the "try to find a short script that will demonstrate the problem" approach might help.

        If, with an empty directory, you try something like:

        use File::Path; foreach my $n ( 0 .. 12 ) { mkpath("/blah/$n", 1, 0755) or die "$n: $!"; }
        do you still get a bogus "/blah/10". And if so, does "strings /blah/10" provide any hints about what the file is?

Re: freaky mkdir problem
by traveler (Parson) on Apr 27, 2001 at 00:22 UTC
    Have you considered using truss or strace, whichever your system has, to see what is actually going on? This might give a clue or two.

    --traveler

      I'm not familiar enough with either truss or strace to get any helpful information I'm afraid. and, of course, I'm under something of a time crunch... or I'd work on fixing that now. thanks in any case...