Hi SelfSimilar,

On Dec 5, 2008, at 3:34 AM, SelfSimilar wrote:
> I get an error message "Use of uninitialized value in numeric gt (>)  
> at
> SFTP_test2.pl line 21" which is the print statement
>
> print $buf while (($len = $chan->read($buf,512)) > 0);
That error (or is it a warning?) means that you tried to compare  
'undef' with a number using the '>' operator. In terms of your code, I  
guess it means that
        $chan->read($buf,512)
returned 'undef'.

So what does *that* mean? According to the documentation for  
Net::SSH2::Channel->read:
        Attempts to read size bytes into the buffer. Returns number of bytes  
read,
        undef on failure. If ext is present and set, reads from the extended  
data
        channel (stderr).
(from http://search.cpan.org/~dbrobins/Net-SSH2-0.18/lib/Net/SSH2/Channel.pm)

So maybe there was a failure reading data from the SSH channel, which  
made $chan->read return undef, causing the warning in your code.

You can test this theory by rewriting that line as:
        while (1) {
                var $len = $chan->read($buf, 512);
                if($len == undef) {
                        print "$chan->read returned undef\n";
                        my ($error_code, $error_name, $error_string) = 
$ssh2->error;
                        print "Error reported by Perl: $!\n" if(defined($!));
                        print "Error reported by SSH: 
$error_code:$error_name:$error_string 
\n" if defined($error_code);
                        exit 0;
                }
                last if ($len < 0);
                print STDERR "Length is zero" if($len == 0);

                print $buf;
        }

If your program exits with a "$chan->read returned undef" message,  
you'll know what's going on. With any luck, it'll also give you an  
error message of some sort, which you can look into that to figure out  
why $chan->read is returning 'undef'.

Hope that helps,
Gaurav
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to