Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Net::SSH2 list files

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

in reply to Re^2: Net::SSH2 list files
in thread Net::SSH2 list files

# 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.

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

    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 :(

      Ok, try this one:
      # untested again! my $sftp = $ssh2->sftp; my $dh = $sftp->opendir($dir); while (my %e = $dh->read) { print "$e{name}\n"; }

      Net::SFTP::Foreign does not require IO::Pty when you use it with the Net::SSH2 backend.

        (-----O-----) *hug*

        Thank you a lot for the help, this seems to work. It prints some extra information if there are some folders in the folder I am looking at but it also prints all the files

        This is what I got:

        ".aptitude, .bashrc, of the files), .cache, .., .bash_history, test.txt(the other file), TestAddDir(the directory in the directory that I am listing), .viminfo, .profile, .debtags, ."

        If you can't be bothered I can probably figure out how to remove these other things that are shown.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986245]
[erix]: I do some work as a corrector (if that's the right word) and often I have to remove phrases that people think is dutch but that is really literally taken from english (and does not exist in dutch. Although at some point it becomes acceptable, of course)
[erix]: "Do not be dafter than you are" doesn't seem a very good translation
LanX understands corrector but thinks it's editor
[LanX]: don't feign ignorance

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-03-19 22:24 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.