Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

package that can handle ftp, sftp, http etc ?

by bittis (Sexton)
on Jul 18, 2008 at 13:17 UTC ( [id://698613]=perlquestion: print w/replies, xml ) Need Help??

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

Hi there
i was wondering if there is one package that can handle all these protocols for transfering files, without the need to use several other packages each handling a different protocol

Thank you :)

  • Comment on package that can handle ftp, sftp, http etc ?

Replies are listed 'Best First'.
Re: package that can handle ftp, sftp, http etc ?
by salva (Canon) on Jul 18, 2008 at 15:51 UTC
    I suppose that actually, your problem is not having to use too many modules, but having to use too many modules with different APIs!

    As already suggested, WWW::Curl supports almost any protocol but has a lot of dependencies, so it could be very difficult to install on some platforms.

    LWP is the de-facto standard in the Perl world and can be easily extended to support new protocols (for instance, my module LWP::Protocol::sftp adds support for SFTP).

    Net::xFTP and Net::uFTP both try to expose a common interface for FTP and SFTP protocols.

      I guess it is a problem of many interfaces rather than packages, well said :)

      One of the requirments of what am writting is that it will be as easy to go through and maintain as possible by my client, and they prefered using one package if possible as they might need to extend it to support different protocols in the future, and they would prefer not having to go through the code to create more handles of other protocols (current requirments are http, ftp, sftp).
      The points made as to why one should use packages instead of resorting to system() calls are also good.

      I did not realise LWP supported sftp, in which case i might as well use it instead of curl, which appears to be too big of a fuss to use right now

        getting SFTP to work can be difficult, specially if you want your programs to run under Windows.

        Currently there are five different SFTP implementations available from CPAN, and no one is perfect:

        • Net::SSH::Perl and Net::SFTP are full implementations of the SSH/SFTP protocols in Perl. The authors took OpenSSH source code and just translated it from C to Perl. It depends on several modules, some of them very difficult to install and nowadays it is mostly unmaintained.
        • Net::SSH2 is a perl wrapper for the excellent libssh2 library. Improving at very good pace, it's a very good option. Its only drawback is that being an XS module it can be difficult to install.
        • Net::SFTP::Foreign (I am its author): a pure Perl implementation of the SFTP protocol that uses the programs ssh or plink to stablish the SSH tunnel. It's very fast, stable and supports several high level methods not available from the other modules (for instance, glob, find, rget, rput). It's mayor drawback is password authentication: Expect (that BTW, doesn't work under ActiveState Perl on Windows) is required to handle it, and even then it has some problems.
        • WWW::Curl: it also uses libssh2 internally to handle SFTP.
        • Net::SFTP::Expect: an Expect wrapper for the sftp binary.

        Currently, LWP::Protocol::sftp is just and adaptor for Net::SFTP::Foreign, though I plan to add support for Net::SSH2 in the no so distance future... patches are also welcome!

        LWP should give you the common interface you're looking for. LWP::Protocol::sftp extends LWP for sftp.

        One of the biggest pitfalls I usually run into with system() calls is having to go around my elbow to find a way to regain control, data, etc.

Re: package that can handle ftp, sftp, http etc ?
by Anonymous Monk on Jul 18, 2008 at 13:32 UTC
    Thats not a wise requirement, but WWW::Curl fits the bill ;)
      Hey thanks for your reply, i was thinking of using curl from the shell actually, but wasn't sure how good that would be. Why do you find that as not being wise? I 'm rather inexpirianced with perl and it would be good to hear opinions :)
        It's more efficient and you have much more control using a perl library than you do when you call an external program. For instance, you can keep the FTP/HTTP/etc. connection open from one call to the next if you make multiple requests to the same server.

        Moreover, calling an external program is fraught with a lot of coding traps and pitfalls. In general I would prefer using a perl module rather than system() whenever possible.

        Btw, why do you need it to be a "single package"? There are ways to bundle CPAN packages together so that you can install all of them with a single command.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://698613]
Approved by Arunbear
Front-paged by salva
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-23 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found