Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Net::SSH2 list files

by salva (Abbot)
on Aug 08, 2012 at 11:49 UTC ( #986236=note: print w/replies, xml ) Need Help??

in reply to Net::SSH2 list files

You have to call Net::SSH2::SFTP::opendir method to get a directory handle object and then read the entries from it.

An easy solution would be to use Net::SFTP::Foreign with the Net::SSH2 backend Net::SFTP::Foreign::Backend::Net_SSH2.

Replies are listed 'Best First'.
Re^2: Net::SSH2 list files
by WhiskeyJack (Initiate) on Aug 08, 2012 at 12:13 UTC

    Thanks for replying salva!

    The problem I have is that I can't figure out a way to read the entries. I can't use Net::SFTP::Foreign at all since I'm on a windows and cygwin is not responding to my pleading :D Is there some other way to get this information from the opendir command?

      # untested! my $sftp = $ssh2->sftp; my $dh = $sftp->opendir($dir); while (my %entries = $dh->read) { print "$_\n" for keys %entries; }

      BTW, Net::SFTP::Foreign works with ActiveState and Strawberry versions of perl.

        When I run it I just get:

        uid, mode, mtime, name, atime, size, gid, uid

        Over and over again instead of getting the 3 files in the folder I defined :(

        Still thank you for trying!

        Net::SFTP::Foreign needs IO/ which is only supported on windows if you run it with cygwin which for me still creates a bunch of problems :(

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986236]
[marto]: think targeted ads
[marto]: "your house is so big, consider product XYZ", "You clean a lot, consider product ABC"
Discipulus your house is so small, accept dollars from nigeria
[marto]: Discipulus, or space saving products, that sort of thing

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-07-26 12:05 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (390 votes). Check out past polls.