Ruby 如何呼叫 net/ftp 介面實作檢視 FTP 伺服器上的檔案列表
PHP中文网
PHP中文网 2017-04-24 09:09:22
0
1
665

環境:
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中文网

认证高级PHP讲师

全部回覆(1)
洪涛

我知道啊,要不要來問我

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板