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 file

Again, 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...


In reply to Net::SFTP::Foreign; plink yield zero length file by spstansbury

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.