rinceWind has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for a way inside Perl, of treating an ftp connection (and possibly other protocols such as rsync or webdav), as if it is a file system. Has anyone done this?

I've looked at IO::All::LWP, which goes a long way. This provides a nice abstraction for individual files - that's if you can entertain using IO::All's somewhat unauthodox interface. But, what I am after is the ability to handle directories, i.e. globbing (which I::A::L doesn't appear to do).

If I'm going to write this, I imagine offering a tied file handle / dirhandle interface. I have existing code, which uses glob and open which could use this directly.

Any pointers, clues or help would be appreciated.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re: Abstraction of FTP as a file system
by marto (Cardinal) on Aug 16, 2006 at 13:16 UTC
    rinceWind,

    You may want to look at FuseFTP "FuseFTP is a FTP filesystem written in Perl."

    Hope this helps.

    Martin

      Thanks for the link. Is this related to the Fuse on CPAN? I wonder why FuseFTP is not on CPAN.

      --

      Oh Lord, won’t you burn me a Knoppix CD ?
      My friends all rate Windows, I must disagree.
      Your powers of persuasion will set them all free,
      So oh Lord, won’t you burn me a Knoppix CD ?
      (Missquoting Janis Joplin)

        rinceWind,

        The documentation I linked to lists Fuse as a prerequisite. I have no idea why this is not on CPAN, I think it looks promising.

        Update: I have emailed the author to find out if this could be uploaded to CPAN. He is already a CPAN author.

        Martin
Re: Abstraction of FTP as a file system
by gellyfish (Monsignor) on Aug 16, 2006 at 13:17 UTC

    I think you'll find that most of what you suggest has already been done - see Filesys::Virtual. The framework provides a mechanism for you to create a Virtual Filesystem over nearly any provider you want.

    /J\

Re: Abstraction of FTP as a file system
by talexb (Chancellor) on Aug 16, 2006 at 18:37 UTC

    I'm working on a web application sort of like an FTP Server -- it's going to have a REST interface as well as a more standard web interface, so my clients will be able to run a script that will make a REST request to upload and download files. Not exactly like mounting an NFS share, but the next best thing, I hope.

    No one's mentioned NET::FTPServer yet .. I am planning to integrate that into my web application and have it talk FTP as well as CGI and REST, so I'll have a tri-mode application.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      Your RESTful interface sounds cool! If you could upload to CPAN or host elsewhere, that would be very useful, as I have several potential applications. Would your interface require apache or work standalone?

      NET::FTPServer is not what I currently need, as my requirements are for an FTP client which looks like a file system.

      --

      Oh Lord, won’t you burn me a Knoppix CD ?
      My friends all rate Windows, I must disagree.
      Your powers of persuasion will set them all free,
      So oh Lord, won’t you burn me a Knoppix CD ?
      (Missquoting Janis Joplin)

        I am working towards making this application a CPAN contribution, always assuming that I can get the higher-ups to go along with the idea (they'll want to retain copyright, of course). All I need to do is make sure all of the company-related stuff is separate from the vanilla product that we upload to CPAN.

        And yes, it runs through Apache .. that's a wheel I decided I didn't want to reinvent, and in fact using Apache makes the REST interface easier, since I use URL rewriting to implement the RESTful interface. I also use cookies, which isn't totally in favour with some RESTafarians, but I find it easier and less problematic to do that than stuff the authentication into the URLs.

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Abstraction of FTP as a file system
by leocharre (Priest) on Aug 16, 2006 at 23:07 UTC

    This may be way off.. I remember once I wanted to casually drop things into a predetermined place in my site. I wanted to drop 'bookmark' files into this directory on my desktop. And hav them magically appear on the site.

    So, I just had a directory and rsync on cron to do this. It's not immediate, but.. For what I wanted it was good and simple.

Re: Abstraction of FTP as a file system
by EvanCarroll (Chaplain) on Aug 18, 2006 at 18:30 UTC
    I'm not exactly sure as to what your asking, but I did some pretty extensive work with perl and proftpd, to make it function as a filesystem of sort, using mod_sql for logging and archiving, and perl for the stored procs.

    You can find more information at howtoforge.com -- my howtoforge tutorial


    Evan Carroll
    www.EvanCarroll.com