[Ssh-sftp-perl-users] get multiple files when name is not known
Brought to you by:
dbrobins
From: Curt S. <csh...@gm...> - 2006-03-15 15:40:59
|
I have to write a process that gets 1 or more files from a remote source, when the exact file name will not be known. I think I have the right logic but it does not appear to be working like I expect. #############begin code################# #!/usr/bin/perl use strict; use Net::SFTP; use Net::SFTP::Util; use Net::SFTP::Constants; my $host = "x.x.x.x"; my $user = "username"; my $pass = "password"; my $cmd = "get"; my $remotedir = "/pub"; my $sftp = Net::SFTP->new("$host",user=>"$user",password=>"$pass",protocol=>"2",debug=> "1"); my @files = $sftp->ls("$remotedir"); foreach (@files){ $sftp->get($_); print "recieving $_...\n"; } print "Complete!\n"; ###############end code####################### What I am getting for each loop in the debug is the following: linuxbox: sftp: Sent message T:17 I:30 linuxbox: sftp: Received stat reply T:101 I:30 Couldn't stat remote file: No such file or directory at ./sftptest line 19 recieving HASH(0x98d9440)... Of course the HASH is different for each loop Line 19 is $sftp->get($_); Is the receipt supposed to be a HASH value or am I missing something. If it is how do I get the filename from that? Thanks Curt |