|
From: kimanhtle on 23 Apr 2008 00:36 On Apr 22, 11:22 pm, "A. Sinan Unur" <1...(a)llenroc.ude.invalid> wrote: > kimanh...(a)gmail.com wrote in news:9c1c4e83-24cb-4a0a-a888-9f191ff99111 > @w7g2000hsa.googlegroups.com: > > > On Apr 22, 6:54 pm, "John W. Krahn" <some...(a)example.com> wrote: > >> kimanh...(a)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 <1...(a)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.
From: John W. Krahn on 23 Apr 2008 02:11 kimanhtle(a)gmail.com wrote: > On Apr 22, 11:22 pm, "A. Sinan Unur" <1...(a)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
From: kimanhtle on 23 Apr 2008 08:19 On Apr 23, 2:11 am, "John W. Krahn" <some...(a)example.com> wrote: > kimanh...(a)gmail.com wrote: > > On Apr 22, 11:22 pm, "A. Sinan Unur" <1...(a)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.
From: Ben Bullock on 23 Apr 2008 08:31 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.
From: Ted Zlatanov on 23 Apr 2008 09:27 On Wed, 23 Apr 2008 05:19:39 -0700 (PDT) kimanhtle(a)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
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: pop langs website ranking Next: FAQ 1.16 How can I convince others to use Perl? |