Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Greetings Monks.

I'm hoping someone with more ActivePerl experience that I can shed some light on the behavior that I'm seeing.

I have a script ( below ) that copies some Nessus scans to another machine for further processing.

When I run the script via perl.exe ( >perl copy_files.wpl ) it runs perfectly.

When I run it via wperl.exe, either on the command line ( >wperl copy_files.wpl ) or via Windows Task Scheduler, it fails with the error: Unable to connect to remote host: Bad ssh command: Invalid argument at C:\Users\Administrator\RiskView\copy_files.wpl line 76.

I believe I have all the required tweaks for wperl - suppressing the window, redirecting STDERR and STDOUT to files, but as wperl.exe is supposed to be identical to perl.exe except for the need to launch a window, I'm at a loss to explain why it won't run the Net::SFTP::Foreign module without error.

As always, thanks for any input!

Best regards, Scott...

file_copy.wpl:

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"; my $error_log = $producer . "_error_log.log"; my $copy_log = $producer . "_log.log"; unlink( $error_log ); unlink( $output_log ); close(STDOUT); open(STDOUT, ">>$output_log"); close(STDERR); open(STDERR, ">>$error_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 = '10.10.10.10'; my $user = 'user'; my $password = 'password'; # Check the copylog for the last set of files loaded my $last_loaded_date; open ( LOG_DATA, "<$copy_log"); while ( my $line = <LOG_DATA>) { chomp $line; next unless( $line =~ /Last Loaded/ ); my @last_loaded_time_line = split( /:/, $line ); $last_loaded_date = $last_loaded_time_line[1]; last; } close ( LOG_DATA); print "Getting files more recent than $last_loaded_date\n"; my $dm1 = new Date::Manip::Date; my $dm2 = $dm1->new_date; my $now_date = $dm1->new_date; my $time_stamp = time; my $err = $now_date->parse( "epoch $time_stamp" ); my $current_date = $now_date->printf( "%Y-%m-%d %H:%M:%S" ); $last_loaded_date =~ s/^\s+//; $last_loaded_date =~ s/\s+$//; $dm1->parse( $last_loaded_date ); 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 chdir $incoming_dir; my @ls1 = @{ $sftp->ls( $nessus_dir, names_only => 1, ordered => 1 ) } +; my $last_loaded; foreach my $dir_date ( @ls1 ) { next unless $dir_date =~ /\d{4}-\d{2}-\d{2}/; $dm2->parse( $dir_date ); if ( $dm1->cmp( $dm2 ) == -1 ) { $sftp->mget( "$nessus_dir/$dir_date/*nessus-results.zip" ) or +die "Unable to transfer files: " . $sftp->error; $last_loaded = $dir_date; print "Getting files from directory $dir_date\n"; } } undef $sftp; open( LOG,">../$copy_log ") or die $!; print LOG "Copied Nessus reports from SecurityCenter\n"; print LOG "Last copy run on: $current_date\n"; print LOG "Last Loaded (directory name): $last_loaded\n"; close( LOG );

In reply to ActivePerl - perl.exe works, wperl.exe does not... 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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (11)
    As of 2014-10-30 16:14 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (208 votes), past polls