我正在尝试使用Matlab中的cURL命令在ftp服务器上获取文件的目录列表。 目前我正在尝试这样的事情:
[s,w] = dos('curl "ftp://name:password@ftpurl/directory/"');它正确地获取数据并将其存储在变量w中。
要获取该目录中的文件列表,我可以尝试从'w'变量中解析出名称,但这可能会有点复杂。 有没有更简单的方法来获取ftp目录中的文件名列表,或者我是否必须尝试从w变量中获取它?
谢谢!
编辑
使用-l命令:
[s,w] = dos('curl "ftp://name:password@ftpurl/directory/"');结果w看起来像:
0 0 0 763 0 0 2319 0 - : - : - 2437FTPtest-D20110322-T022705.bot
FTPtest-D20110322,T022705.idx
FTPtest-D20110322,T022705.raw
FTPtest-D20110322-T022746.bot
所以它看起来好多了,但由于第一个文件以前没有换行,可能会有点困难。 关于如何解决这个问题的任何想法?
谢谢!
I'm trying to get a directory listing of files on an ftp server using cURL commands within Matlab. Currently I'm trying something like:
[s,w] = dos('curl "ftp://name:password@ftpurl/directory/"');which correctly gets the data and stores it in the variable w.
To get a list of the files in that directory I could try to parse out the names from the 'w' variable, but that could get a little complicated. Is there an easier way to obtain a list of the file names within the ftp directory, or do I have to go about trying to grab it out of the w variable?
Thanks!
EDIT
Using the -l command:
[s,w] = dos('curl "ftp://name:password@ftpurl/directory/"');The resulting w looks something like:
0 0 0 763 0 0 2319 0 --:--:-- 2437FTPtest-D20110322-T022705.bot
FTPtest-D20110322-T022705.idx
FTPtest-D20110322-T022705.raw
FTPtest-D20110322-T022746.bot
So it looks much better, but since the first file doesn't have a line feed before, it may be a little more difficult. Any ideas on how to get around this?
Thanks!
最满意答案
尝试-l(这是一个小写的L)选项:
列出FTP目录时,此开关会强制使用仅限名称的视图。 如果要机器解析FTP目录的内容,特别有用,因为普通目录视图不使用标准外观或格式。
此选项会导致发送FTP NLST命令。 某些FTP服务器仅列出对NLST的响应中的文件; 它们不包含子目录和符号链接。
(引自http://curl.haxx.se/docs/manpage.html#-l )
Try the -l (that's a lowercase L) option:
When listing an FTP directory, this switch forces a name- only view. Especially useful if you want to machine-parse the contents of an FTP directory since the normal directory view doesn't use a standard look or format.
This option causes an FTP NLST command to be sent. Some FTP servers list only files in their response to NLST; they do not include subdirectories and symbolic links.
(quote originates from http://curl.haxx.se/docs/manpage.html#-l)
更多推荐
发布评论