Re: [Ssh-sftp-perl-users] Exclude directories in $sftp->ls()??
Brought to you by:
dbrobins
From: Kevin S. <kev...@gm...> - 2008-02-01 16:46:59
|
On Jan 29, 2008 6:58 AM, Fredrik Stridfeldt <str...@gm...> wrote: > Hello! > > Iam writing a script for automated download and send of files using NET:SFTP. > Just ran into following problem: > > In my sub for fetching files i do like this to figure out what files > are present in the directory on the remote server. > > foreach ($sftp->ls($ddir)) { > next if ($_->{filename} =~ m/^\./); > next if (-d "$ddir\/$_->{filename}"); > push(@files, $_->{filename}); > } > return (@files); > > I exclude . and .. but to exclude the directories i have no success. I > use the same loop with (-d) for excluding directories locally when i > send files and that works with a smile.. > > Best Regards > plura I've used the parse_dir() function from File::Listing for parsing directory lists provided by $sftp->ls() in the past with some success. -- Kevin. |