通过 Perl(或其他语言)中的 ftp 递归远程目录树,仅将文件层次结构信息填充到 MySQL 中 - 查找现有库
我想通过 FTP 使用远程目录中的信息(即不是文件/文件夹本身,而是它们的名称+其他信息)填充 MySQL 数据库,保留文件的分层位置。
我正在寻找执行部分或全部操作的现有库,特别是解析从 ftp 输出返回的文本/字符串。
我已经在这里做了一些研究,但没有发现任何足够接近的东西:
FTP 递归...如果我已经有该文件如何跳过它 已经有该文件?(可能是 有用)
如何遍历远程 (ftp) 使用 Perl 的目录树?(非常 关闭但有差评 这个模块,例如显然,正则表达式 被破坏并且它不会递归到 目录,这是真的吗?在那里 有效的示例?
从单个网站下载所有图像 网站的目录(这使用HTTP而不是FTP,但概念相似,但不能直接用于我的情况)
我将使用以下方法在MySQL中存储文件层次结构:
只是想在我可能重新发明轮子之前先问一下。如果我没有得到答案,我会假设我所要求的内容还不完全存在,所以我会发布我的方法(就像我在此处发布的其他不同问题一样)。如果您能提供建议,请提前致谢。
使用 Perl 来执行此操作不是强制性的,任何其他跨平台语言都可以,例如 C、C++、Java、PHP、Python。只是我目前对 Perl 很“熟悉”,使用它做了很多工作,但我对其他语言持开放态度,这些语言已经用列出的大多数语言进行了广泛的编程。
I want to populate a MySQL database with the information (i.e. not the files/folders themselves but their names+ other info) from a remote directory via FTP, retaining the hierarchical positions of the files.
I'm looking for existing libraries that do some or all of this, particularly the parsing of the text/strings returned from ftp output.
I've done some research here already but not found anything quite close enough:
How can I read a file's contents
directly with Perl's Net::FTP?FTP Recursive…how to skip it if I
already have the file? (might be
useful)How do I traverse a remote (ftp)
directory tree with Perl? (very
close but there are bad reviews of
this module, e.g. apparently, regex
is broken and it doesn't recurse into
directories, is this true? are there
examples that work?Download all images from a single
directory of a website (this uses HTTP not FTP, but the concept is similar but not directly usable for my situation)
I would use the following approach to store the file hierachy in MySQL:
Just thought I would ask before I potentially re-invent the wheel. If I don't get answers I'll assume what I'm asking for doesn't exist in entirety yet so I would post what my approach would be (as I have done with other, different questions I have posted here). Thanks in advance if you can offer advice though.
Using Perl to do this is not mandatory, any other cross platform language would be OK, e.g. C, C++, Java, PHP, Python. It's just that I'm "in-the-zone" with Perl doing a lot of work using it at the moment but am open to other languages having programmed extensively with most of those listed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ncftpls 你可以列出远程目录,然后你可以用Perl 或任何其他语言。您将需要
-R
选项来递归子目录。With ncftpls you can do a remote directory listing, and then you can parse it with Perl or any other language. You will need the
-R
option to recurse through subdirectories.