I was trying to write a nice tar pipe tar system in a perl script, and got to this, which I think can be useful:

#!/usr/bin/perl use Archive::Tar; use Net::SSH; my $tar = Archive::Tar->new; my $dir = "/path/to/dir"; # Copy files from dir without recursion my @files = glob("$dir/*"); $tar->add_files(@files); $user = "root"; $host = "myhost.example.org"; $cmd = "cd / && tar xf -"; Net::SSH::sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; print WRITER $tar->write; close(WRITER); close(READER);

If you know of a nicer way to do it, I'm open to ideas :)