SPUG: Regarding Perl and file transfers

Colin Meyer cmeyer at helvella.org
Thu Jul 24 15:29:25 PDT 2008

On Thu, Jul 24, 2008 at 01:57:29PM -0800, Christopher Howard wrote:
> Since I started learning Perl, I've focused almost exclusively on Perl 
> CGI.  I'm just starting to learn about networking with Perl.
> I want to create scripts to do all the computer-to-computer backups on 
> my personal LAN.  My first thought was to use SFTP because it secure and 
> it is easy to set up an SFTP server.  And I saw Net::SFTP so I thought 
> I'd learn how to use that.

While I like using Perl for many computer tasks, machine to machine
backups are perhaps best accomplished with an off-the-shelf solution. I
use rsync to backup a directory tree from one machine to another. One
nice thing about rsync is that it copies blockwise diffs of files, so it
only transmits changed data each time you sync. If security is a
concern, you can configure rsync to use an encrypted channel via ssh.

> Right away I ran into problems using Net::SFTP.  It is probably either
> the way that I installed it or the way I tried to use it.  But
> nevertheless, I notice that Net::SFTP is only on version 0.10...
> So I take that to mean that Perl programmers do not commonly use SFTP
> for communicating files with their scripts.  

Version numbers of CPAN modules can be a funny thing. I use some modules
that have a pretty low version number. If I'm concerned about the
maturity of a module, I'll look for a community (email list, wiki, irc,
etc.). If there's an active community of users and developers, that's a
good sign. Author responsiveness is another good sign.

> Then, what protocol is
> commonly used?  Do I need to learn to make those complicated-looking
> scripts for creating socket connections?

You'll only need to learn low level socket interactions if you intend on
inventing your own network protocol, or communicating with a protocol that
there isn't a CPAN module for.

Probably the easiest protocol for communicating between two processes
(likely on different machines) is REST with a JSON payload. There isn't
a single module that embeds everything for you, but if you've ever
written a CGI program, you will find the concept to be easy to grasp.

There's also JSON-RPC, which is very easy to implement with the
JSON::RPC CPAN module. The only downside is that JSON-RPC is less common
than REST. If you aren't planning on exposing your services to the
outside world, then this isn't a problem.

Hope this helps,

More information about the spug-list mailing list