取消
显示结果 
搜索替代 
您的意思是: 

Access FTP with whitespaces in dir names

已解决!
转到解答

Hi, 

 

I'm trying to make a recursive list of files in an FTP directory.

 

While FileZilla deals with whitespaces in directory names with no problem, it seems that Labview struggles a bit.

 

Indeed, if I ask labview to get the files and directory of a folder named, for instance, /Projects/Camera 1/, it will return an empty array (while FileZilla clearly sees 12 files in this folder). It seems that the problem is the whitespace in the name because if I replace (using FileZilla) the space character with "_", LV correctly gives me the file list.

 

Any idea how to make the LabView FTP function correctly deal with whitespaces in directory and file names?

 

Best regards,

 

perper2001

0 项奖励
1 条消息(共 13 条)
23,527 次查看

Try to replace the white space with %20

2 条消息(共 13 条)
23,522 次查看

Thanks for your reply.

 

Unfortunately, replacing whitespaces with %20 doesn't work.

 

Regards,

 

peper2001

0 项奖励
3 条消息(共 13 条)
23,517 次查看

The %20 syntax is HTTP escaping. It will only work in a web browser (with FTP support) which will convert the HTTP escaping to proper FTP syntax. Have you tried to enclose the entire file path in double quotes ("/Projects/Camera 1/")?

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 项奖励
4 条消息(共 13 条)
23,508 次查看

Yep, i've tried enclosing the path with double quotes but it returns an empty file list.

 

What does work however is changing the current working directory (CWD) and then using the labview directory listing function with no file path. But it won't work with commands like /Projects/Camera 1/*.jpg.

 

What also work is using NLST instead of LIST (just modify a boolean in directory listing vi) but, with this function all files and directory are not correclty recognized and are detected as "link". 

 

What also work is using MLSD but the reply string is not compatible with the one that LIST returns and hence, the reply string is not correclty parsed.

 

I think my best option is to go with MLSD and rewrite the parsing algorithm... but if someone as a better option, I'm all hears!

 

Regards,

 

peper2001

0 项奖励
5 条消息(共 13 条)
23,495 次查看

FYI, it works OK with the MLSD function.

0 项奖励
6 条消息(共 13 条)
23,432 次查看

@peper2001 wrote:

FYI, it works OK with the MLSD function.


That is very possible. I haven't checked the FTP RFC in a while. Most likely they added those new commands to accomodate these new things explicitedly. Doesn't have to mean that an FTP server couldn't support quoted paths with the standard commands, but that is a feature of your FTP server, not of the client you use to talk to the server. So LabVIEW can't do anything about this here. It is mainly a feature that your FTP server has to provide and there might be differences between different FTP servers.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 项奖励
7 条消息(共 13 条)
23,420 次查看

OK, thanks for pointing that out.

 

Best regards,

 

peper2001

0 项奖励
8 条消息(共 13 条)
23,409 次查看

peper2001,

     I'm running into the same issue. The LIST command works with many FTP servers, but fails on some servers to return files and directories if the directory name contains spaces. Of the various work-arounds you describe, the MSLD command sounds like the best approach, since the others have limitations. You mentioned that you got that to work. Is there any chance you could share some code? From what see, the MSLD command isn't even supported in the low-level FTP functions LabVIEW supplies. I don't imagine it would be too hard to figure out how to implement it, using the existing commands as a guide. But if you've done it already, that would be even easier!

     I put in a support request with NI when this happened. They pointed me toward your post. I'm going to suggest that they improve the FTP VI's that ship with LV to help address this. But it's not unlikely that the quickest solution will be if the community can provide one. If I am able to get MSLD (possibly with your help), I'll be glad to package it up into something that can be posted to the community.

Thanks,

     DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 项奖励
9 条消息(共 13 条)
23,173 次查看
解答
接受人 Dave_Thomson

Hi,

 

Unfortunately, I can't share the code but here is a screenshot of what it looks like.  It is based on the "directory listing vi" that is shipped with labview.

 

MLSD.png

It basically send the MLSD command, and wait for the reply. After that, it's a matter of parsing the reply of the server which, on my FTP, looks like this:

type=cdir;sizd=3;modify=20150220090455;UNIX.mode=0705;UNIX.uid=32210;UNIX.gid=100;unique=d8g863beb0; .
type=pdir;sizd=5;modify=20150302165245;UNIX.mode=0705;UNIX.uid=32210;UNIX.gid=100;unique=d8g863beae; ..
type=dir;sizd=12;modify=20150302000236;UNIX.mode=0705;UNIX.uid=32210;UNIX.gid=100;unique=d8g863beb2; Camera pile 9

 Regards,

 

peper

10 条消息(共 13 条)
23,165 次查看