Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
...i.e. run ufsdump in a sub-process, grab the output and channel it to standard out of the perl process. The script works, but each time it print anything, it reprints everything that's been sent to standard output since the start of the programme! Howvere, it only does this with the redirect to the file; writing to the terminal comes out as expected.sub perform_dump { print "\nDumping the discs...\n"; foreach my $disc (@discs) { print "...$disc...\n"; local (*HIS_IN, *HIS_OUT, *HIS_ERR); my $cmd = '/usr/sbin/ufsdump'; my @args = ('0luf', '/dev/rmt/1n', $disc); my $pid = open3 (*HIS_IN, *HIS_OUT, *HIS_ERR, $cmd, @args); print while (<HIS_ERR>); wait; &barf ('dump-fail', $disc) if $? != 0; } }
Is this a Perl bug, a module bug in IPC::Open3, a feature, or did I just screw up?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print behaving badly
by I0 (Priest) on Dec 18, 2000 at 18:56 UTC | |
|
Re: print behaving badly
by merlyn (Sage) on Dec 18, 2000 at 20:15 UTC | |
by chipmunk (Parson) on Dec 18, 2000 at 20:22 UTC | |
|
Re: print behaving badly
by repson (Chaplain) on Dec 19, 2000 at 07:25 UTC |