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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |