Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   Can't stat e:: Unknown file or directory ??? (http://www.velocityreviews.com/forums/t25408-cant-stat-e-unknown-file-or-directory.html)

Abe 11-23-2004 12:10 AM

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.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.

Jim Gibson 11-23-2004 09:00 PM

Re: Can't stat e:: Unknown file or directory ???
 
In article <ptv4q09117auos26c0lk2gvcoeg954d3p5@4ax.com>, Abe
<mark-news@PLEASE.NOSPAM.gags-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.

Abe 11-24-2004 01:48 AM

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.arc.nasa.gov> wrote:

>In article <ptv4q09117auos26c0lk2gvcoeg954d3p5@4ax.com>, Abe
><mark-news@PLEASE.NOSPAM.gags-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.


All times are GMT. The time now is 06:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57