----- Original Message -----
From: "SelfSimilar" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, December 05, 2008 6:34 AM
Subject: NET::SSH2 - No Output
> After successfully establishing a SSH connection I use the following code
> snippet, variations of which have been posted many places.
>
> my $chan = $ssh2->channel();
> $chan->shell();
> $chan->blocking(0);
> my ($len, $buf);
> $chan->write("ls\n");
> select(undef,undef,undef,0.25);
> print $buf while (($len = $chan->read($buf,512)) > 0);
As an alternative, that could be replaced with:
my $chan = $ssh2->channel();
my ($len, $buf) = (1000, ' ' x 1000);
$chan->exec("ls\n");
$chan->read($buf, $len);
print $buf, "\n";
One problem with that replacement code is that you need to allocate a
sufficiently large buffer ($buf). It doesn't matter if $buf is larger than
necessary, but if it's smaller than needed then you miss out on the "extra"
data.
>
> I get an error message "Use of uninitialized value in numeric gt (>) at
> SFTP_test2.pl line 21" which is the print statement
It's not an error message - it's a warning which you could eliminate with
(at the beginning of your script):
no warnings 'uninitialized';
I get the same warning with your code, but I also get the "ls" output
printed out before the warning appears. Is it the same for you ?
Are you using perl 5.8.x or 5.10.0 ?
Cheers,
Rob
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs