in reply to help with Print
#!/usr/bin/perl use strict; use warnings; use diagnostics; open(LOG, '>', '/root/Desktop/log.out') or die "Can't redirect stdout: + $!"; open(CMD, 'ls |'); open(STDERR, '>&', STDOUT) or die "Can't redirect stderr: $!"; open(STDERR, '>', 'LOG_FILE') or die "Can't redirect stderr: $!"; print "\nhere1\n"; while (<CMD>) { print_stuff ($_); } sub print_stuff { my ($line) = @_; print LOG $line; print $line; } print "\nhere2\n"; close LOG; close CMD; close STDERR; exit;
|
|---|