File::Remote

File::Remote is a Perl module to read/write/edit remote files transparently.
Download

File::Remote Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Nathan Wiger, Sun Microsystems
  • Publisher web site:
  • http://search.cpan.org/~nwiger/File-Remote-1.17/Remote.pm

File::Remote Tags


File::Remote Description

File::Remote is a Perl module to read/write/edit remote files transparently. File::Remote is a Perl module to read/write/edit remote files transparently.SYNOPSIS # # Two ways to use File::Remote # # First, the function-based style. Here, we can use the # special :replace tag to overload Perl builtins! # use File::Remote qw(:replace); # special :replace tag # read from a remote file open(REMOTE, "host:/remote/file") or die $!; print while (< REMOTE >); close(REMOTE); # writing a local file still works! open(LOCAL, ">>/local/file"); print LOCAL "This is a new line.n"; close(LOCAL); mkdir("host:/remote/dir", 0755); unlink("host:/remote/file"); unlink("/local/file"); # still works too! symlink("host:/remote/src", "host:/remote/dest"); chown("root", "other", "host:/remote/dir/file"); chmod(0600, "host:/remote/dir/file"); # # Next, the object-oriented style, if you don't want to # mess with the builtins. # use File::Remote; my $remote = new File::Remote; # Standard filehandles $remote->open(FILE, ">>host:/remote/file") or die $!; print FILE "Here's a line that's added.n"; $remote->close(FILE); # Create a new file and change its permissions $remote->mkdir("host:/remote/dir"); $remote->touch("host:/remote/dir/file"); # Move files around $remote->copy("/local/file", "host:/remote/file") or warn $!; $remote->move("host:/remote/file", "/local/file"); # Read and write whole files my @file = $remote->readfile("host:/remote/file"); $remote->writefile("/local/file", @file); # Backup a file with a suffix $remote->backup("host:/remote/oldfile", "save"); # Use secure connection methods my $secure = new File::Remote (rsh => "/usr/local/bin/ssh", rcp => "/usr/local/bin/scp"); $secure->unlink("/local/file"); $secure->rmdir("host:/remote/dir");This module takes care of dealing with files regardless of whether they're local or remote. It allows you to create and edit files without having to worry about their physical location on the network. If a file passed into a function is of the form host:/path/to/file, then File::Remote uses rsh/rcp (or ssh/scp, depending on how you configure it) to edit the file remotely. Otherwise, it assumes the file is local and passes calls directly through to Perl's core functions.The nice thing about this module is that you can use it for all your file calls, since it handles both remote and local files transparently. This means you don't have to put a whole bunch of checks for remote files in your code. Plus, if you use the function-oriented interface along with the :replace tag, you can actually redefine the Perl builtin file functions. This means that your existing Perl scripts can automatically handle remote files with no re-engineering(!). Requirements: · Perl


File::Remote Related Software