- 注册时间
- 2010-10-22
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 2292
- 在线时间
- 小时
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?欢迎注册
×
试了下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.
复制代码 |
|