G-Spider 发表于 2013-5-18 12:43:07

难道是perl中的bug ?

试了下perl中的Net::SSH2模块,似乎有个bug。
为了在windows平台玩一下SSH2,在本机上安装了个Bitvise SSH Server (WinSSHD)。
调用scp_get,发现Net::SSH2::scp_get得到的文件大小不正确,本应该为9字节,得到的却为0,奇怪的是atime的值与size相符。
问题行:my $chan = $self->_scp_get($remote, \%stat);
而scp_put没有这个问题,使用了stat方式,得到正确的文件相关的信息。sub scp_get {
    my ($self, $remote, $path) = @_;
    $path = basename $remote if not defined $path;
    my %stat;
    my $chan = $self->_scp_get($remote, \%stat);
    return unless $chan;

    print join(":",%stat);
    print "\nfile size=",$stat{size};
    <>;...
===================$ssh2->debug(1)后的输出============================libssh2_scp_recv(ss->session, path, &st) -> 0x2e995e4
uid:0:mtime:0:mode:420:atime:9:size:0:gid:00
Net::SSH2::Channel::read(size = 1, ext = 0)
- read 1 bytes
- read 1 total
Net::SSH2::Channel::DESTROY

Net::SSH2::DESTROY object 0x21d1664=================================================================
api参考:NAME
libssh2_scp_recv - request a remote file via SCP
SYNOPSIS
#include <libssh2.h>

LIBSSH2_CHANNEL * libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);


DESCRIPTION
session - Session instance as returned by libssh2_session_init_ex(3)

path - Full path and filename of file to transfer. That is the remote file name.

sb - Populated with remote file's size, mode, mtime, and atime

Request a file from the remote host via SCP.
RETURN VALUE
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
ERRORS
LIBSSH2_ERROR_ALLOC - An internal memory allocation call failed.

LIBSSH2_ERROR_SCP_PROTOCOL -

LIBSSH2_ERROR_EAGAIN - Marked for non-blocking I/O but the call would block.
SEE ALSO
libssh2_session_init_ex(3) libssh2_channel_open_ex(3)


This HTML page was made with roffit.

mathematica 发表于 2013-5-22 16:02:00

你上传一个文本文件也好呀!难道你没发现论坛经常把代码解析错误吗?
这也是我经常不用代码写公式而用图片的原因之一!

mathematica 发表于 2017-4-11 09:21:27

你居然用perl

mathematica 发表于 2017-4-11 09:25:14

我最不喜欢没有注释的程序
页: [1]
查看完整版本: 难道是perl中的bug ?