Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
A round of thank you's and upvotes to all the Really Fine Monks who responded to my question.   8^)

mattr hit the nail on the head, when he said "erase every appearance in @all of each element in @err", as did Zaxo with "relies on error log to contain everything to be rejected... dependency on both logs having error messages in same order."

Code below works fine on Cygwin and Debian with included sample data, but blows it on real rsync.pl data.   ~daaang~

    cheers,
    Don
    striving toward Perl Adept
    (it's pronounced "why-bick")
#!/usr/bin/perl -w # rtest9.pl $|++; # stdout hot use strict; # avoid d'oh! bugs require 5; # for following modules use Cwd 'chdir'; # move to particular directory use Tie::IxHash; # insertion-order retrieval for hash # my $logDir = '/cygdrive/C/Rsync/logs'; my $logDir = '/home/joe/rtest'; my $allLog = "all.log"; my $errLog = "err.log"; my $dirLog = "dir.log"; my $fileLog = "file.log"; chdir "$logDir"; open ALL, "< $allLog" or die $!; my @all = <ALL>; close ALL or die $!; open ERR, "< $errLog" or die $!; my @err = <ERR>; close ERR or die $!; tie my %allCount, "Tie::IxHash"; $allCount{$_}++ for( @all, @err ); my (@dirfile, @errchk); for( keys %allCount ) { if ( $allCount{$_} == 1 ) { push @dirfile, $_; } else { push @errchk, $_; } } my (@dir, @file); for(@dirfile){ if ( $_ =~ /\// ) { push @dir, $_; } else { push @file, $_; } } open DIR, "> $dirLog" or die $!; print DIR "$_" for(@dir); close DIR or die $!; open FIL, "> $fileLog" or die $!; print FIL "$_" for(@file); close FIL or die $!; =pod == all.log == file1 file2 error1 error2 file3 dir1/ dir2/ == err.log == error1 error2 =cut

And here's my latest efforts.   Now using File::Rsync.   Not completely out of the woods, but making progress...

#!/usr/bin/perl -w # rsf.pl # pod at tail $|++; # stdout hot use strict; # avoid d'oh! bugs require 5; # for following modules use File::Rsync; # wrapper for rsync directory sync tool my $logDir = '/home/joe/rtest'; my $outLog = "$logDir/out.log"; my $errLog = "$logDir/err.log"; ## RECEIVE my $srchost = 'indy:'; # my @src = qw(perls debs); my $src = 'perls'; my $dest = '/home/joe/rtest/'; ## SEND # my $srchost = ''; # my @src = qw(/home/joe/rtest /usr/local/perls); # my $dest = 'indy::Test'; my $obj = File::Rsync->new({ srchost => $srchost, src => \@src, dest => $dest, }); # src => $src, $obj->defopts({ archive => 1, verbose => 1, recursive => 1, owner => 1, perms => 1, group => 1, times => 1, debug => 0, compress => 0, 'dry-run' => 0, }); $obj->exec or warn "Rsync notice - check logs\n"; open OUT, "> $outLog" or die $!; open ERR, "> $errLog" or die $!; my @out = $obj->out; print OUT for(@out); my @err = $obj->err; my $stat = $obj->status; my $rstat = $obj->realstatus; print ERR for(@err); print OUT "status = $stat\n"; print OUT "realstatus = $rstat\n"; close OUT or die $!; close ERR or die $!; =head1 UPDATE 2002-03-11 16:45 CST Variableized object options Test on Cygwin rsh=>'/usr/bin/ssh' errs, ignored Debug sending to rsync server user@rhost::module only with rsh=>'/usr/local/bin/ssh' "@list=$obj->list" is only for no "dest" 2002-03-09 22:15 CST Initial working code =head1 TODO Figure out File::Rsync syntax to receive from multiple rsync modules @ERROR: Unknown module 'mod1 mod2' There is also a method for passing multiple source paths to a remote system by passing the remote hostname to the srchost key and passing an array ref to the source key... single trailing colon on the name... Loopify somehow for send+receive Re-test on Cygwin Pod::Usage Getopt::Long ? Logfile::Rotate ? ? Parallel::ForkManager ? =cut

In reply to Re: Save 2 files' diff as 3rd file (working code) by ybiC
in thread Save 2 files' diff as 3rd file by ybiC

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 chanting in the Monastery: (14)
    As of 2014-09-19 14:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (139 votes), past polls