问题
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