Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WWWXXXAPC, WWWXXX .CMD, Wwwwxxx reemine, WWWXXX.VCBA, WWWXXX.VCBA, TheboL.wwwxxxxx, WWWXXXAPC , wwwxxn.xsss, wwwxxxapc, WWWXXX.VCBA

Links

XODOX
Impressum

#1: Recursive directory read with File::Find

Posted on 2008-04-23 00:43:54 by kimanhtle

I would like to do a recursive read of a directory on my local
computer. Is this possible with File::Find? If not, is there any other
way to do it in Perl?

Report this message

#2: Re: Recursive directory read with File::Find

Posted on 2008-04-23 00:54:03 by someone

kimanhtle@gmail.com wrote:
> I would like to do a recursive read of a directory on my local
> computer. Is this possible with File::Find?

Yes.

> If not, is there any other way to do it in Perl?

TMTOWTDI

http://search.cpan.org/search?query=File%3A%3AFind&mode=all


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Report this message

#3: Re: Recursive directory read with File::Find

Posted on 2008-04-23 05:14:23 by kimanhtle

On Apr 22, 6:54 pm, "John W. Krahn" <some...@example.com> wrote:
> kimanh...@gmail.com wrote:
> > I would like to do a recursive read of a directory on my local
> > computer. Is this possible with File::Find?
>
> Yes.
>
> > If not, is there any other way to do it in Perl?
>
> TMTOWTDI
>
> http://search.cpan.org/search?query=File%3A%3AFind&mode=all
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall


Thanks! Would you happen to have an example? I only got it to work for
a UNIX path not a path on my local computer. It could be I didn't
escape the path right. For example, if I have "C:\projects\docs
\HUNGER_AWARENESS_04212008", would I have to pass it as "C:\\projects\
\docs\\HUNGER_AWARENESS_04212008"?

Report this message

#4: Re: Recursive directory read with File::Find

Posted on 2008-04-23 05:21:52 by someone

kimanhtle@gmail.com wrote:
>
> On Apr 22, 6:54 pm, "John W. Krahn" <some...@example.com> wrote:
>>
>> kimanh...@gmail.com wrote:
>>>
>>> I would like to do a recursive read of a directory on my local
>>> computer. Is this possible with File::Find?
>>
>> Yes.
>>
>>> If not, is there any other way to do it in Perl?
>>
>> TMTOWTDI
>>
>> http://search.cpan.org/search?query=File%3A%3AFind&mode=all
>
> Thanks! Would you happen to have an example? I only got it to work for
> a UNIX path not a path on my local computer. It could be I didn't
> escape the path right. For example, if I have "C:\projects\docs
> \HUNGER_AWARENESS_04212008", would I have to pass it as "C:\\projects\
> \docs\\HUNGER_AWARENESS_04212008"?

Or 'C:/projects/docs/HUNGER_AWARENESS_04212008' should work as well.


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Report this message

#5: Re: Recursive directory read with File::Find

Posted on 2008-04-23 05:22:53 by 1usa

kimanhtle@gmail.com wrote in news:9c1c4e83-24cb-4a0a-a888-9f191ff99111
@w7g2000hsa.googlegroups.com:

> On Apr 22, 6:54 pm, "John W. Krahn" <some...@example.com> wrote:
>> kimanh...@gmail.com wrote:
>> > I would like to do a recursive read of a directory on my local
>> > computer. Is this possible with File::Find?
>>
>> Yes.
>>
>> > If not, is there any other way to do it in Perl?
>>
>> TMTOWTDI
>>
>> http://search.cpan.org/search?query=File%3A%3AFind&mode=all
>>
>> John
>> --

[ don't quote sigs ]

>
> Thanks! Would you happen to have an example? I only got it to work for
> a UNIX path not a path on my local computer. It could be I didn't
> escape the path right. For example, if I have "C:\projects\docs
> \HUNGER_AWARENESS_04212008", would I have to pass it as "C:\\projects\
> \docs\\HUNGER_AWARENESS_04212008"?

From perlfaq5:

Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp
\foo.exe` work?

We are not going to write your code for you when the documentation
contains both working examples and answers to frequently answered
questions.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Report this message

#6: Re: Recursive directory read with File::Find

Posted on 2008-04-23 06:36:32 by kimanhtle

On Apr 22, 11:22 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> kimanh...@gmail.com wrote in news:9c1c4e83-24cb-4a0a-a888-9f191ff99111
> @w7g2000hsa.googlegroups.com:
>
> > On Apr 22, 6:54 pm, "John W. Krahn" <some...@example.com> wrote:
> >> kimanh...@gmail.com wrote:
> >> > I would like to do a recursive read of a directory on my local
> >> > computer. Is this possible with File::Find?
>
> >> Yes.
>
> >> > If not, is there any other way to do it in Perl?
>
> >> TMTOWTDI
>
> >>http://search.cpan.org/search?query=File%3A%3AFind&mode=al l
>
> >> John
> >> --
>
> [ don't quote sigs ]
>
>
>
> > Thanks! Would you happen to have an example? I only got it to work for
> > a UNIX path not a path on my local computer. It could be I didn't
> > escape the path right. For example, if I have "C:\projects\docs
> > \HUNGER_AWARENESS_04212008", would I have to pass it as "C:\\projects\
> > \docs\\HUNGER_AWARENESS_04212008"?
>
> From perlfaq5:
>
> Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp
> \foo.exe` work?
>
> We are not going to write your code for you when the documentation
> contains both working examples and answers to frequently answered
> questions.
>
> Sinan
>
> --
> A. Sinan Unur <1...@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:http://www.rehabitation.com/clpmisc/

$upload_dir = 'C:\projects\docs\HUNGER_AWARENESS_04212008';
$upload_dir =~ s/\\/\//g;
find(\&handleFind, $upload_dir);

sub handleFind {
my $foundFile = $File::Find::name;
print "$foundFile and $_<br/>\n";
}

That was what I tried and it did not print the results of the
directory. But thank you all for taking the time to reply and bearing
with a newbie. I believe it is b/c my Perl script is on a UNIX server
that is trying to read directories on a local PC.

Report this message

#7: Re: Recursive directory read with File::Find

Posted on 2008-04-23 08:11:10 by someone

kimanhtle@gmail.com wrote:
> On Apr 22, 11:22 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>>
>> From perlfaq5:
>>
>> Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp
>> \foo.exe` work?
>
> $upload_dir = 'C:\projects\docs\HUNGER_AWARENESS_04212008';
> $upload_dir =~ s/\\/\//g;
> find(\&handleFind, $upload_dir);
>
> sub handleFind {
> my $foundFile = $File::Find::name;
> print "$foundFile and $_<br/>\n";
> }
>
> That was what I tried and it did not print the results of the
> directory. But thank you all for taking the time to reply and bearing
> with a newbie. I believe it is b/c my Perl script is on a UNIX server
> that is trying to read directories on a local PC.

UNIX does not have drive letters like 'C:' so it makes no sense to use
that as part of the path on a UNIX system.

So the question then becomes how are you accessing the directories "on a
local PC"? Via SMB? NFS? FTP? SSH? ???


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Report this message

#8: Re: Recursive directory read with File::Find

Posted on 2008-04-23 14:19:39 by kimanhtle

On Apr 23, 2:11 am, "John W. Krahn" <some...@example.com> wrote:
> kimanh...@gmail.com wrote:
> > On Apr 22, 11:22 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>
> >> From perlfaq5:
>
> >> Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp
> >> \foo.exe` work?
>
> > $upload_dir = 'C:\projects\docs\HUNGER_AWARENESS_04212008';
> > $upload_dir =~ s/\\/\//g;
> > find(\&handleFind, $upload_dir);
>
> > sub handleFind {
> > my $foundFile = $File::Find::name;
> > print "$foundFile and $_<br/>\n";
> > }
>
> > That was what I tried and it did not print the results of the
> > directory. But thank you all for taking the time to reply and bearing
> > with a newbie. I believe it is b/c my Perl script is on a UNIX server
> > that is trying to read directories on a local PC.
>
> UNIX does not have drive letters like 'C:' so it makes no sense to use
> that as part of the path on a UNIX system.
>
> So the question then becomes how are you accessing the directories "on a
> local PC"? Via SMB? NFS? FTP? SSH? ???
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall

I am at a dead end. I was trying to use the file upload field to have
user select a file then use javascript to get the directory name of
that file. This directory name was passed to a CGI script which I
thought I could use to traverse the directory listing recursively.
Then the CGI script would upload all the files in this directory.
However, now I am stuck at finding a way to recursively read a
directory on my local PC.

Report this message

#9: Re: Recursive directory read with File::Find

Posted on 2008-04-23 14:31:38 by benkasminbullock

On Wed, 23 Apr 2008 05:19:39 -0700, kimanhtle wrote:

> I am at a dead end. I was trying to use the file upload field to have
> user select a file then use javascript to get the directory name of that
> file. This directory name was passed to a CGI script which I thought I
> could use to traverse the directory listing recursively. Then the CGI
> script would upload all the files in this directory. However, now I am
> stuck at finding a way to recursively read a directory on my local PC.

There isn't any way for the Unix server to read the directory on your
local PC solely via a web browser, at least unless you totally disable
all security in the browser or something. Imagine if it was possible to
do things like that, we'd all be in serious trouble! You can send the
string containing the directory to the Unix server, but unless the Unix
server has some file system type of connection to your local PC (that is
the "SMB? NFS? FTP? SSH?" stuff which JK mentioned), it's not possible
to look at the PC's file system with either a CGI script or JavaScript.
That is just the nature of web servers and browsers.

Report this message

#10: Re: Recursive directory read with File::Find

Posted on 2008-04-23 15:27:04 by Ted Zlatanov

On Wed, 23 Apr 2008 05:19:39 -0700 (PDT) kimanhtle@gmail.com wrote:

k> I am at a dead end. I was trying to use the file upload field to have
k> user select a file then use javascript to get the directory name of
k> that file. This directory name was passed to a CGI script which I
k> thought I could use to traverse the directory listing recursively.
k> Then the CGI script would upload all the files in this directory.
k> However, now I am stuck at finding a way to recursively read a
k> directory on my local PC.

Unfortunately the currently available standards only let you upload one
file at a time. On the client, make a ZIP (or other format) archive of
the whole directory tree of interest and upload that. On the server,
open and examine the archive with Archive::Zip or whatever module is
appropriate for the archive format you've chosen.

Ted

Report this message

#11: Re: Recursive directory read with File::Find

Posted on 2008-04-23 16:23:13 by kimanhtle

On Apr 23, 9:27=A0am, Ted Zlatanov <t...@lifelogs.com> wrote:
> On Wed, 23 Apr 2008 05:19:39 -0700 (PDT) kimanh...@gmail.com wrote:
>
> k> I am at a dead end. I was trying to use the file upload field to have
> k> user select a file then use javascript to get the directory name of
> k> that file. This directory name was passed to a CGI script which I
> k> thought I could use to traverse the directory listing recursively.
> k> Then the CGI script would upload all the files in this directory.
> k> However, now I am stuck at finding a way to recursively read a
> k> directory on my local PC.
>
> Unfortunately the currently available standards only let you upload one
> file at a time. =A0On the client, make a ZIP (or other format) archive of
> the whole directory tree of interest and upload that. =A0On the server,
> open and examine the archive with Archive::Zip or whatever module is
> appropriate for the archive format you've chosen.
>
> Ted

Thank you all so much for your help.
Ben, you are right, I did think of the security issue. But my boss
kept telling me there was a way to do recursive find. I searched the
web and found I could use an applet and then a perl script in the
backend. However, boss did not approve using applet.
Ted, the zip method was my last resort which I have working.

Report this message

#12: Re: Recursive directory read with File::Find

Posted on 2008-04-23 19:01:37 by hjp-usenet2

On 2008-04-23 12:31, Ben Bullock <benkasminbullock@gmail.com> wrote:
> On Wed, 23 Apr 2008 05:19:39 -0700, kimanhtle wrote:
>> I am at a dead end. I was trying to use the file upload field to have
>> user select a file then use javascript to get the directory name of that
>> file. This directory name was passed to a CGI script which I thought I
>> could use to traverse the directory listing recursively. Then the CGI
>> script would upload all the files in this directory. However, now I am
>> stuck at finding a way to recursively read a directory on my local PC.
>
> There isn't any way for the Unix server to read the directory on your
> local PC solely via a web browser, at least unless you totally disable
> all security in the browser or something. Imagine if it was possible to
> do things like that, we'd all be in serious trouble! You can send the
> string containing the directory to the Unix server, but unless the Unix
> server has some file system type of connection to your local PC (that is
> the "SMB? NFS? FTP? SSH?" stuff which JK mentioned), it's not possible
> to look at the PC's file system with either a CGI script or JavaScript.

I think it is possible to give signed JavaScript the permission to do
this (similar to signed applets). But I've never looked at the details
and it's off-topic in this group anyway.

hp

Report this message

#13: Re: Recursive directory read with File::Find

Posted on 2008-04-24 01:45:06 by 1usa

"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote in
news:slrng0uqri.5jo.hjp-usenet2@hrunkner.hjp.at:

> On 2008-04-23 12:31, Ben Bullock <benkasminbullock@gmail.com> wrote:
....

>> unless the Unix server has some file system type of connection to
>> your local PC (that is the "SMB? NFS? FTP? SSH?" stuff which JK
>> mentioned), it's not possible to look at the PC's file system with
>> either a CGI script or JavaScript.
>
> I think it is possible to give signed JavaScript the permission to do
> this (similar to signed applets). But I've never looked at the details
> and it's off-topic in this group anyway.

AFAIK, works only on Firefox. So, if that is a suitable restriction for
the OP, the next place to check is Firefox documentation on how to do
it.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

Report this message