Hi Monks I'm using 7zip inside a Perl script but for the life of me I can't get Perl to output what 7zip is doing in real time. I get output from 7zip after it has achived some stuff first. Running the same command through a command prompt in Windows each time 7zip compresses a file it tells you so. The files are large 4GB+

I've tried multiple flush methods found via your site.

#local $| = 1; #$| = 0; #$|++; #use constant {OUTPUT_AUTOFLUSH_BUFFERED =>0, # OUTPUT_AUTOFLUSH_UNBUFFERED=>1}; #$| = OUTPUT_AUTOFLUSH_UNBUFFERED; #use IO::Handle; #STDERR->autoflush(1); #STDOUT->autoflush(1);

Example below

$exclude_list = " -x!*RECYCLE.BIN -x!*Thumbs.db -x!*desktop.ini"; print "$now $package: Exclude List: " . $exclude_list . "\n\n"; $now = timestamp(); print "$now $package: Commencing ZIP to $target_path\n"; chdir $source or die "$package: Could not chdir $source, Error: $!\n"; #my $command = $zip_cmd . ' a -r -mx0 -tzip' . $exclude_list . ' ' . $ +sysvolume . ' ' . $target_zip . ' '; # Form the Zip command #my $command = "$zip_cmd a -r -mx0 -tzip $exclude_list $sysvolume $tar +get_zip "; # Form the Zip command my $result = `( $command ) 2>&1`; #$monitor_flag and print STDOUT "$command\n"; $monitor_flag and print STDOUT "$result\n"; my $ZIP = undef; open($ZIP,"$result |") or die "$package: Could not open pipe for $resu +lt, Error: $!\n"; #open($ZIP,"$command |") or die "$package: Could not open pipe for $co +mmand, Error: $!\n"; while (my $line = <$ZIP>) { print $line; $trace and print STDOUT $line; } close $ZIP;

http://www.perlmonks.org/?node_id=960000

http://www.perlmonks.org/?node_id=280025

http://www.perlmonks.org/?node=How%20do%20I%20flush%2Funbuffer%20an%20output%20filehandle%3F%20Why%20must%20I%20do%20this%3F

http://www.perlmonks.org/?node_id=20590

http://www.perlmonks.org/?node_id=669369

http://www.perlmonks.org/?node_id=20590

http://www.perlmonks.org/?node_id=280025


In reply to Caturing 7zip output with Perl by Anonymous Monk

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.