当目录包含一个或多个空格时,Ruby Net :: FTP会引发错误

时间:2013-12-24 11:07:20

标签: ruby ftp

我正在尝试使用ftp.list(parent_path)

爬行我的FTP站点

每当parent_path变量包含空格时,我都会收到以下错误

Ftp LIST exception: Net::FTPPermError detail: 550 /Download/Dimension: The system cannot find the file specified.

Ftp LIST exception: the parent_path (if present) was : /Download/Dimension Data

这是我的代码段

begin
  @logger.error("on #{ip} : " + ftp.system())
  entry_list = parent_path ? ftp.list("#{parent_path}") : ftp.list
rescue => detail
  retries_count += 1
  @logger.error("on #{ip} : Ftp LIST exception: " + detail.class.to_s + " detail: " + detail.to_s)
  @logger.error("on #{ip} : Ftp LIST exception: the parent_path (if present) was : " + parent_path)

我尝试使用\来转义空格,我尝试使用%20,不知道还有什么可以尝试......

非常感谢任何有关如何让ftp.list兑现或逃离空间的想法,想法,建议等!

1 个答案:

答案 0 :(得分:0)

您使用的是Windows吗?当ftp站点的操作系统是Windows时,会出现此问题。我将所有空间都改为下划线。我希望有更好的解决方案。