if (lc($transfertype) eq "get"){ $sftp_connection->setcwd($remote_dir); foreach my $file (@file_globs){ my @files = $sftp_connection->glob($file); foreach my $element (@files){ #if the remote file is a directory, we want to skip it. if (${$element}{longname} =~ /^d.*$/){ next; } else { $sftp_connection->get(${$element}{filename}, $local_dir.${$element}{filename}); if ($sftp_connection->error == 0){ &logEntry($args{'logfile'}, "$jobname--Getting remote file: \/".$remote_dir.${$element}{filename}); } elsif ($sftp_connection->error != 0){ &logEntry($args{'logfile'}, "$jobname-ERROR: ".$sftp_connection->error); } if ($delete_remote_files == 1){ $sftp_connection->remove(${$element}{filename}); if ($sftp_connection->error == 0){ &logEntry($args{'logfile'}, "$jobname--Deleting remote file:\/".$remote_dir."\/".${$element}{filename}); } elsif ($sftp_connection->error != 0){ &logEntry($args{'logfile'}, "$jobname-ERROR: ".$sftp_connection->error." - ${$element}{filename}"); } } } } } }