找回密码
 欢迎注册
查看: 6705|回复: 5

[讨论] 难道是perl中的bug ?

[复制链接]
发表于 2013-5-18 12:43:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
试了下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方式,得到正确的文件相关的信息。
  1. sub scp_get {
  2.     my ($self, $remote, $path) = @_;
  3.     $path = basename $remote if not defined $path;
  4.     my %stat;
  5.     my $chan = $self->_scp_get($remote, \%stat);
  6.     return unless $chan;

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

  7. Net::SSH2::DESTROY object 0x21d1664
复制代码
=================================================================
api参考:
  1. NAME
  2. libssh2_scp_recv - request a remote file via SCP
  3. SYNOPSIS
  4. #include <libssh2.h>

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


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

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

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

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

  15. LIBSSH2_ERROR_SCP_PROTOCOL -

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


  19. This HTML page was made with roffit.
复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2013-5-22 16:02:00 | 显示全部楼层
你上传一个文本文件也好呀!难道你没发现论坛经常把代码解析错误吗?
这也是我经常不用代码写公式而用图片的原因之一!
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2017-4-11 09:21:27 | 显示全部楼层
你居然用perl
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2017-4-11 09:25:14 | 显示全部楼层
我最不喜欢没有注释的程序
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-26 09:01 , Processed in 0.047536 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表