Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Net::SSH2 list files

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


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

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.


Comment on Re^5: Net::SSH2 list files
Download Code
Replies are listed 'Best First'.
Re^6: Net::SSH2 list files
by WhiskeyJack (Initiate) on Aug 08, 2012 at 12:56 UTC

    (-----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, ssh22.pl(one 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.

      look at the other fields on the hash returned by $dh->read, they probably contain enough information to let you filter out non file entries.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2015-07-30 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls