Seeking to practice the Perl virtue of laziness, I pose the following
problem and question:
My former ISP allocated me personal web space wherein every time I
created a new directory with an FTP program, the server automatically
created an index.html page for that directory. This page refreshed
the links it indexed every time I created/deleted a file from a
particular directory. The page was basic HTML -- no stylesheet, no
nuttin -- but it Just Worked.
My new ISP does *not* automatically generate an index.html page when I
upload/delete/rename files via FTP. As a result, I cannot easily
browse through the directories in my web space; every link has to be
manually typed.
I would like to write a Perl script which provides File::Find-like
capabilities for traversing directory trees and modifying files found
therein with the power of FTP. Specifically, I would like the script
to:
1. Establish a connection with the FTP part of my ISP's service via
Net::FTP (with which I am somewhat familiar).
2. Traverse the directory structure of my FTP site much as File::Find
would, with the objective of getting a complete picture of the
directory tree.
3. On the fly, create index.html pages for each directory with links
to the parent directory (if public) and all files and subdirectories
found therein.
4. Upload the new index.html pages to the appropriate directories via
Net::FTP, then log off.
I would be surprised if I were the first person to have/want to do
this. I looked at the listings under FTP on search.cpan.org, but none
seemed to leap out and say, "I'm the one you want, baby."
Suggestions for avoidance of reinvention of wheels? Thanks in
advance.
jimk
Sherm Pendley - 26 Apr 2004 14:46 GMT
> Suggestions for avoidance of reinvention of wheels? Thanks in
> advance.
What you're describing sounds like a *lot* of unnecessary work. You're
approaching it from the wrong direction, which is probably why you're not
finding any modules to help.
It sounds like what your old ISP did is just auto-indexing on the web
server. That is, if there is no index.html (or other index document), the
server simply generated a list of files.
If your server is Apache, create a file named ".htaccess" at the top level
of your web site, or edit it if it's already there. Add the following:
Options +Indexes
Note that the server admins may have disabled this ability. If you're
certain your server is Apache, and the above fails, ask your admin for
help.
sherm--

Signature
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Jim Keenan - 26 Apr 2004 22:10 GMT
> What you're describing sounds like a *lot* of unnecessary work. You're
> approaching it from the wrong direction, which is probably why you're not
[quoted text clipped - 3 lines]
> server. That is, if there is no index.html (or other index document), the
> server simply generated a list of files.
Probably true.
> If your server is Apache, create a file named ".htaccess" at the top level
> of your web site, or edit it if it's already there. Add the following:
>
> Options +Indexes
>
> Note that the server admins may have disabled this ability.
Almost certainly so.
> If you're
> certain your server is Apache, and the above fails, ask your admin for
> help.
I'm not even going to bother, not because your suggestion isn't good,
but because this is just a home DSL account with Verizon where (a) the
personal web space is a freebie they toss in on the expectation that
most customers aren't going to use it or expect anything other than
what Verizon offers them in terms of functionality and (b) I have
never yet gotten Verizon to respond to an e-mail -- and they have
never provided me with the phone number for a help desk. Because I
expect so little of Verizon, I want to have as little to do with them
as possible and want the solution to be under my control as much as
possible, which means doing it in Perl.
jimk
Gerard Lanois - 27 Apr 2004 03:50 GMT
> 1. Establish a connection with the FTP part of my ISP's service via
> Net::FTP (with which I am somewhat familiar).
> 2. Traverse the directory structure of my FTP site much as File::Find
> would, with the objective of getting a complete picture of the
> directory tree.
Article:
http://www.foo.be/docs/tpj/issues/vol4_4/tpj0404-0009.html
Source code:
http://home.san.rr.com/lanois/perl/downloads/tpj16.tar.gz
> 3. On the fly, create index.html pages for each directory with links
> to the parent directory (if public) and all files and subdirectories
> found therein.
> 4. Upload the new index.html pages to the appropriate directories via
> Net::FTP, then log off.
You'll have to add these parts yourself. The above article should
be enough to get you started.
-Gerard
Jim Keenan - 27 Apr 2004 14:29 GMT
> Article:
>
> http://www.foo.be/docs/tpj/issues/vol4_4/tpj0404-0009.html
I'm only halfway through the article and I can tell it will be *very* helpful.
> Source code:
>
[quoted text clipped - 8 lines]
> You'll have to add these parts yourself. The above article should
> be enough to get you started.
Thanks, Gerard. I'll report back when I get results.
Jim Keenan