Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Net::SSH2 list files

by WhiskeyJack (Initiate)
on Aug 08, 2012 at 11:35 UTC ( #986228=perlquestion: print w/replies, xml ) Need Help??
WhiskeyJack has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Is there some way for me to list all the files in a folder on my SFTP server using Net::SSH2. Right now I'm using a shell script but that won't work because the program will be run on several different operating systems.

Thanks in Advance

Replies are listed 'Best First'.
Re: Net::SSH2 list files
by salva (Abbot) on Aug 08, 2012 at 11:49 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://986228]
Approved by Corion
[Discipulus]: amitkumarj441 more atention you put asking, more attentio you got in answers
Discipulus 's hoping he needs a oneliner ;=)
VinsWorldcom takes a cookie from the platter on the sideboard.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2017-04-26 20:29 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (488 votes). Check out past polls.