Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Can't stat e:: Unknown file or directory ???

Reply
Thread Tools

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

 
 
Abe
Guest
Posts: n/a
 
      11-23-2004
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.
 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      11-23-2004
In article <(E-Mail Removed)>, Abe
<(E-Mail Removed)-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.
 
Reply With Quote
 
 
 
 
Abe
Guest
Posts: n/a
 
      11-24-2004
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
<(E-Mail Removed)> wrote:

>In article <(E-Mail Removed)>, Abe
><(E-Mail Removed)-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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.stat() distorts filenames that end with period (nt.stat()) ruck Python 10 09-07-2012 05:54 AM
Why do I have to prefix stat from <sys/stat.h> with the keyword struct? Rolf Krüger C++ 2 03-12-2008 10:38 PM
Date & Time representation in "struct stat" - <sys/stat.h> Magesh C Programming 3 10-05-2007 12:13 PM
struct stat st; stat(fileName.c_str(), &st); hu? Steven T. Hatton C++ 3 06-02-2005 01:50 PM
os.stat('<filename>')[stat.ST_INO] on Windows Patrick Useldinger Python 6 03-03-2005 09:21 AM



Advertisments