|
试了下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) -> 0x2e995e4uid:0:mtime:0:mode:420:atime:9:size:0:gid:00Net::SSH2::Channel::read(size = 1, ext = 0)- read 1 bytes- read 1 totalNet::SSH2::Channel::DESTROYNet::SSH2::DESTROY object 0x21d1664
复制代码 =================================================================
api参考:- NAMElibssh2_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); DESCRIPTIONsession - 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 VALUEPointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors. ERRORSLIBSSH2_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 ALSOlibssh2_session_init_ex(3) libssh2_channel_open_ex(3) This HTML page was made with roffit.
复制代码 |
|