spstansbury has asked for the wisdom of the Perl Monks concerning the following question:
Ever Gracious Monks,
I have a script that I'm running out of Task Scheduler (ActivePerl 5.12, Windows Server 2008 R2, connecting to linux).
The script connects fine, but the mget returns zero length files. It returns all the files in the remote directory, but all zero length.
use strict; use warnings; use Date::Manip; use Archive::Zip; use Net::SFTP::Foreign; use Data::Dumper; BEGIN { Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow +; } my $producer = "file_copy" my $output_log = $producer . "_output_log.log"; unlink( $output_log ); close(STDOUT); open(STDOUT, ">>$output_log" ); close(STDERR); open(STDERR, ">>$output_log" ); # Nessus directory my $nessus_dir = '/opt/sc4/orgs/1/VDB'; my $incoming_dir = 'C:\\Users\\Administrator\\Incoming'; # Data file directory my $data_dir = 'C:\\Users\\Administrator\\Data'; my $host = '255.255.255.255'; my $user = 'xxxxxxx'; my $password = 'xxxxxxx'; # Find the target results directory - look for yesterday's results my $yesterday = ( time - 86400 ); my $dm = Date::Manip::Date->new; $dm->parse( "epoch $yesterday" ); my $daily_results_dir = $dm->printf( "%Y-%m-%d" ); # Change this to load specific day's results $daily_results_dir = "2011-09-10"; no warnings 'Net::SFTP::Foreign'; my $sftp = Net::SFTP::Foreign->new( $host, user => $user, password => +$password, ssh_cmd => 'plink' ); $sftp->error and die "Unable to connect to remote host: " . $sftp->err +or; # Get the files $sftp->mget( "$nessus_dir/$daily_results_dir/*nessus-results.zip", "$i +ncoming_dir"); undef $sftp; # unzip the files. chdir $data_dir; opendir ( INCOMING_FILES, $incoming_dir ) or die "Can't open directory + $incoming_dir: $!"; for ( readdir INCOMING_FILES ) { next unless $_ =~ /zip$/; print "$_\n"; my $az = Archive::Zip->new( "$incoming_dir\\$_" ); $az->extractTree(); } # Delete the zipped files in the Incoming directory unlink ( glob ( "$incoming_dir\\*nessus-results.zip")) or warn "can't +delete files: $!";
The output log shows
Unable to transfer files: 0 at copy_files.wpl line 56, <DATA> line 496.Thinking that it might be a mget/plink thing, I tried running pscp from the command line, and got the error
Write error.. Waiting for the end of fileAgain, it wrote the local file name, but no more. Permissions on the Windows box? the files are all .zip files from the linux box...
Thanks for any insight - Scott...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SFTP::Foreign; plink yield zero length file
by salva (Canon) on Sep 20, 2011 at 07:46 UTC | |
by spstansbury (Monk) on Sep 20, 2011 at 15:09 UTC | |
|
Re: Net::SFTP::Foreign; plink yield zero length file
by spstansbury (Monk) on Sep 19, 2011 at 19:32 UTC |