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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abe

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

    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.t xt";
    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::n ame\n";
    }
    }


    ** Due to SPAM I no longer receive email responses to
    ** newsgroup postings, so don't bother.
  • Jim Gibson

    #2
    Re: Can't stat e:: Unknown file or directory ???

    In article <ptv4q09117auos 26c0lk2gvcoeg95 4d3p5@4ax.com>, Abe
    <mark-news@PLEASE.NOS PAM.gags-r-us.org> wrote:
    [color=blue]
    > 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.[/color]

    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;
    [color=blue]
    > use File::Find;
    > use warnings;
    >
    > @disks = ('h:','g:','f:' ,'e:','d:');[/color]

    my @disks = ... # for this and all other variables
    [color=blue]
    >
    > $rfile = "sharebug.t xt";
    > open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
    >
    > foreach $disk (@disks)[/color]
    foreach my $disk ( @disks )
    [color=blue]
    > {
    > printf ">>>Search disk: %s\n", $disk;
    > printf OFILE ">>>Search disk: %s\n", $disk;
    > @dir = ($disk);[/color]

    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.
    [color=blue]
    > find (\&wanted, @dir);
    > $dir = ();[/color]

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

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

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

    Comment

    • Abe

      #3
      Re: Can't stat e:: Unknown file or directory ???

      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
      <jgibson@mail.a rc.nasa.gov> wrote:
      [color=blue]
      >In article <ptv4q09117auos 26c0lk2gvcoeg95 4d3p5@4ax.com>, Abe
      ><mark-news@PLEASE.NOS PAM.gags-r-us.org> wrote:
      >[color=green]
      >> 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.[/color]
      >
      >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;
      >[color=green]
      >> use File::Find;
      >> use warnings;
      >>
      >> @disks = ('h:','g:','f:' ,'e:','d:');[/color]
      >
      >my @disks = ... # for this and all other variables
      >[color=green]
      >>
      >> $rfile = "sharebug.t xt";
      >> open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
      >>
      >> foreach $disk (@disks)[/color]
      >foreach my $disk ( @disks )
      >[color=green]
      >> {
      >> printf ">>>Search disk: %s\n", $disk;
      >> printf OFILE ">>>Search disk: %s\n", $disk;
      >> @dir = ($disk);[/color]
      >
      >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.
      >[color=green]
      >> find (\&wanted, @dir);
      >> $dir = ();[/color]
      >
      >You don't need this in any case. There is no relation between $dir and
      >@dir (other than they live in the same glob).
      >[color=green]
      >> }
      >> close (OFILE);
      >> exit;
      >>
      >> sub wanted
      >> {
      >> use warnings;[/color]
      >
      >There is no need to repeat 'use warnings' here.
      >[color=green]
      >> $fname = $_;
      >> if (-d $fname)
      >> {
      >> printf OFILE "$File::Find::n ame\n";
      >> }
      >> }[/color]
      >
      >Last suggestion: post further questions to comp.lang.perl. misc. This
      >newsgroup is defunct.[/color]


      ** Due to SPAM I no longer receive email responses to
      ** newsgroup postings, so don't bother.

      Comment

      Working...