Hi
llass61,
See 'read.pl' in the 'example' folder that's part of the Net-SSH2 source distro.
The following, based partly on 'read.pl' and partly on the sample you provided runs fine for me:
use Net::SSH2;
use IO::Scalar;
use strict;
my $host = "192.168.0.3";
my $handle = IO::Scalar->new;;
my $ssh2 = &connect($host,'user','pass');
sub connect
{
my $host = $_[0];
my $user = $_[1];
my $pw = $_[2];
my $ssh2 = Net::SSH2->new();
$ssh2->connect($host);
if ($ssh2->auth_password($user, $pw))
{
print "\nIN SFTP\n";
$ssh2->scp_get('./Documents/trig.c', $handle);
print "Error: ", $ssh2->error(), "\n";
$handle->seek(0, 0);
_read($handle);
}
$ssh2->disconnect();
return $ssh2;
}
sub _read {
my $handle = shift;
while (my $line = <$handle>) {
print $line;
}
}
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.