Read SFTP directories and Sub directories using perl Net::SFTP or Net::SFTP::Foriegn

青春壹個敷衍的年華 提交于 2021-01-28 03:02:46

问题


I am using Net::SFTP::Foriegn module to connect the SFTP server and I could make the connection successfully.

I would like to read each and every directories and sub directories in the SFTP server to get some files. Is it possible?

And, is there any way to differentiate file and directory using this module?


回答1:


use find method to find the entries and then use get method

$sftp->find(\@paths, %opts) Does a recursive search over the given directory $path (or directories @path) and returns a list of the entries found or the total number of them on scalar context.

Every entry is a reference to a hash with two keys: filename, the full path of the entry; and a, a Net::SFTP::Foreign::Attributes object containing file atime, mtime, permissions and size.



来源:https://stackoverflow.com/questions/32267356/read-sftp-directories-and-sub-directories-using-perl-netsftp-or-netsftpfor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!