使用Matlab中的cURL列出ftp上的文件(List files on ftp using cURL in Matlab)

编程入门 行业动态 更新时间:2024-10-21 13:38:59
使用Matlab中的cURL列出ftp上的文件(List files on ftp using cURL in Matlab)

我正在尝试使用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)

更多推荐

本文发布于:2023-08-04 13:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415972.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   cURL   Matlab   ftp   files

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!