#!/usr/bin/perl use strict; use warnings; use Net::SFTP; my $host = '127.0.0.1'; my %args = ( user => 'tinyos', ssh_args => [ port => "22" ] ); my $sftp = Net::SFTP->new($host, %args); my $ls = $sftp->ls('/home/user/Monks'); print "$_->{filename}\n" for (@$ls); __END__ $ perl test.pl benchmark.pl~ Foo sample.pl test.log out.txt sample.pl~ .. .. .. #### #!usr/bin/perl use strict; use warnings; use Net::SFTP::Foreign; my %args = ( host => "127.0.0.1", user => "user", port => "22", # psw => "psw", # uncomment if you are using passwords key_path => "/home/user/.ssh/id_rsa" ); # comment if you are using passwords my $sftp = Net::SFTP::Foreign->new(%args); $sftp->die_on_error("Unable to establish SFTP connection"); my $ls = $sftp->ls('/home/user/Monks') or die "unable to retrieve directory: ".$sftp->error; print "$_->{filename}\n" for (@$ls); __END__ $ perl test.pl benchmark.pl~ Foo sample.pl test.log out.txt sample.pl~ .. .. ..