搜索

首页  >  问答  >  正文

Ruby 如何调用 net/ftp 接口实现查看 FTP 服务器上的文件列表

环境:
ftp服务器上存在/A/B目录,目录下有个文件夹ABC,向获取ftp服务器上文件夹ABC下的文件列表

代码:在irb上测试

require 'net/ftp'
ftp = Net::FTP.open("200.200.0.3","test","test")
ftp.voidcmd("CWD /A/B")
ftp.nlst("ABC")-------这里报错:

报错内容


irb(main):234:0* ftp.nlst("ABC") SocketError: getnameinfo: ���������������������� from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:1083:in `addr' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:1083:in `block (2levels) in <class:BufferedSocket>' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:383:in `makeport' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:421:in `transfercmd' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:514:in `block (2 levels) in retrlines' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:512:in `block in retrlines' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:511:in `retrlines' from D:/Sangfor-ATT/Ruby200/lib/ruby/2.0.0/net/ftp.rb:744:in `nlst' from (irb):234 from D:/Sangfor-ATT/Ruby200/bin/irb:12:in `<main>'

不知道哪里出了错误,向各位大牛求教

PHP中文网PHP中文网2776 天前647

全部回复(1)我来回复

  • PHP中文网

    PHP中文网2017-04-24 09:11:22

    我知道啊,要不要来问我

    回复
    0
  • 取消回复