This code seems to work but breaks on large files due to out of memory issues. I would think the file needs to be written out to file periodicly instead of cached in memory until the xfer completes or fails but I do not know quite how to go about it. We would use this to make backups of directories on remote machines with out creating a tar ball on the remote machine.
Does anyone know how to make it work with very large files?
use Net::SSH::Perl
# vars to set: $user, $password, $host, $local_fqn, $rmt_dir
open STDOUT, ">$local_fqn" or die "Can't redirect stdout";
select STDOUT; $| = 1; # make unbuffered
$cmd="tar -czf - $rmt_dir";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $password);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
close STDOUT;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|