Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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 data.   ~daaang~

    striving toward Perl Adept
    (it's pronounced "why-bick")
#!/usr/bin/perl -w # $|++; # 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 # # 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

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, 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
  • 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (10)
    As of 2019-11-12 16:02 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (66 votes). Check out past polls.