Can't stat e:: Unknown file or directory ???

Discussion in 'Perl' started by Abe, Nov 23, 2004.

  1. Abe

    Abe Guest

    I have a strange Perl problem I don't understand. I've written the
    following program to scan different disks on a Windows server to look
    for directory files. Works fine until it gets to 'e:' when I get this
    warning:

    Can't stat e:: Unknown file or directory

    (If I don't have the "use warnings" in the code I get no message.)

    There are folders and files on e:. I don't understand what the
    problem is but I suspect there's some kind of syntax issue.

    use File::Find;
    use warnings;

    @disks = ('h:','g:','f:','e:','d:');

    $rfile = "sharebug.txt";
    open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";

    foreach $disk (@disks)
    {
    printf ">>>Search disk: %s\n", $disk;
    printf OFILE ">>>Search disk: %s\n", $disk;
    @dir = ($disk);
    find (\&wanted, @dir);
    $dir = ();
    }
    close (OFILE);
    exit;

    sub wanted
    {
    use warnings;
    $fname = $_;
    if (-d $fname)
    {
    printf OFILE "$File::Find::name\n";
    }
    }


    ** Due to SPAM I no longer receive email responses to
    ** newsgroup postings, so don't bother.
    Abe, Nov 23, 2004
    #1
    1. Advertising

  2. Abe

    Jim Gibson Guest

    In article <>, Abe
    <-r-us.org> wrote:

    > I have a strange Perl problem I don't understand. I've written the
    > following program to scan different disks on a Windows server to look
    > for directory files. Works fine until it gets to 'e:' when I get this
    > warning:
    >
    > Can't stat e:: Unknown file or directory
    >
    > (If I don't have the "use warnings" in the code I get no message.)
    >
    > There are folders and files on e:. I don't understand what the
    > problem is but I suspect there's some kind of syntax issue.


    If it were a syntax issue, perl would tell you about it. It is more
    likely a permissions issue. I don't have a Windows server to test your
    program, however. It looks like your syntax is fine.

    I can make some suggestions:


    use strict;

    > use File::Find;
    > use warnings;
    >
    > @disks = ('h:','g:','f:','e:','d:');


    my @disks = ... # for this and all other variables

    >
    > $rfile = "sharebug.txt";
    > open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
    >
    > foreach $disk (@disks)

    foreach my $disk ( @disks )

    > {
    > printf ">>>Search disk: %s\n", $disk;
    > printf OFILE ">>>Search disk: %s\n", $disk;
    > @dir = ($disk);


    You don't need to define an array to pass to find(). Perl will form an
    array from all of your parameters and pass it to the subroutine.
    Therefore, 'find ( \&wanted, $disk );' works fine.

    > find (\&wanted, @dir);
    > $dir = ();


    You don't need this in any case. There is no relation between $dir and
    @dir (other than they live in the same glob).

    > }
    > close (OFILE);
    > exit;
    >
    > sub wanted
    > {
    > use warnings;


    There is no need to repeat 'use warnings' here.

    > $fname = $_;
    > if (-d $fname)
    > {
    > printf OFILE "$File::Find::name\n";
    > }
    > }


    Last suggestion: post further questions to comp.lang.perl.misc. This
    newsgroup is defunct.
    Jim Gibson, Nov 23, 2004
    #2
    1. Advertising

  3. Abe

    Abe Guest

    Thanks. I just posted a slightly cleaned up version in the other
    newsgroup.

    I don't think it's a permission problem because if I change the
    "@disk=" line to this:

    @disks = ('h:','g:','f:','e:\\','d:');

    It handles all the drives just fine.


    On Tue, 23 Nov 2004 13:00:29 -0800, Jim Gibson
    <> wrote:

    >In article <>, Abe
    ><-r-us.org> wrote:
    >
    >> I have a strange Perl problem I don't understand. I've written the
    >> following program to scan different disks on a Windows server to look
    >> for directory files. Works fine until it gets to 'e:' when I get this
    >> warning:
    >>
    >> Can't stat e:: Unknown file or directory
    >>
    >> (If I don't have the "use warnings" in the code I get no message.)
    >>
    >> There are folders and files on e:. I don't understand what the
    >> problem is but I suspect there's some kind of syntax issue.

    >
    >If it were a syntax issue, perl would tell you about it. It is more
    >likely a permissions issue. I don't have a Windows server to test your
    >program, however. It looks like your syntax is fine.
    >
    >I can make some suggestions:
    >
    >
    >use strict;
    >
    >> use File::Find;
    >> use warnings;
    >>
    >> @disks = ('h:','g:','f:','e:','d:');

    >
    >my @disks = ... # for this and all other variables
    >
    >>
    >> $rfile = "sharebug.txt";
    >> open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
    >>
    >> foreach $disk (@disks)

    >foreach my $disk ( @disks )
    >
    >> {
    >> printf ">>>Search disk: %s\n", $disk;
    >> printf OFILE ">>>Search disk: %s\n", $disk;
    >> @dir = ($disk);

    >
    >You don't need to define an array to pass to find(). Perl will form an
    >array from all of your parameters and pass it to the subroutine.
    >Therefore, 'find ( \&wanted, $disk );' works fine.
    >
    >> find (\&wanted, @dir);
    >> $dir = ();

    >
    >You don't need this in any case. There is no relation between $dir and
    >@dir (other than they live in the same glob).
    >
    >> }
    >> close (OFILE);
    >> exit;
    >>
    >> sub wanted
    >> {
    >> use warnings;

    >
    >There is no need to repeat 'use warnings' here.
    >
    >> $fname = $_;
    >> if (-d $fname)
    >> {
    >> printf OFILE "$File::Find::name\n";
    >> }
    >> }

    >
    >Last suggestion: post further questions to comp.lang.perl.misc. This
    >newsgroup is defunct.



    ** Due to SPAM I no longer receive email responses to
    ** newsgroup postings, so don't bother.
    Abe, Nov 24, 2004
    #3
    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. Steven T. Hatton
    Replies:
    3
    Views:
    9,694
    Pete Becker
    Jun 2, 2005
  2. Patrick Useldinger

    os.stat('<filename>')[stat.ST_INO] on Windows

    Patrick Useldinger, Feb 27, 2005, in forum: Python
    Replies:
    6
    Views:
    1,155
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Mar 3, 2005
  3. Magesh
    Replies:
    3
    Views:
    431
    Gordon Burditt
    Oct 5, 2007
  4. Rolf Krüger
    Replies:
    2
    Views:
    607
    Ian Collins
    Mar 12, 2008
  5. ruck
    Replies:
    10
    Views:
    1,258
Loading...

Share This Page