Cool. I didn't know about the IPC::Open3 module. Will look at it. Thanks for the pointer!
deb At 15:04:25, on 06.23.03: Cracks in my tinfoil beanie allowed John W. Krahn to seep these bits into my brain:, > Deb wrote: > > > > I've got a script which opens a filehandle to write print statments to a file. > > But, I'm also running some system commands, and I would also like to send > > stdout and stderr to that filehandle. I could just echo text to a file, or I > > could use a filehandle. Which would be "better?" > > > > my $log = "/tmp/log.$$"; > > > > open(LOG, ">$log"); > > print LOG "Commencing maintenance\n"; > > > > But, here's how I've handled stdout and stderr in a system statement: > > > > my $log = "/tmp/log.$$"; > > > > system("path-to-command >> $log 2>&1"); > > > > Is there a way to use a filehandle instead? Seems I'd have to take care of > > block and non-blocking I/O. Methinks it may be simpler just to stick with > > printing directly to $log and not the FH, LOG. > > You could do something like this: > > use IPC::Open3; > > my $log = "/tmp/log.$$"; > > open LOG, '>', $log or die "Cannot open $log: $!"; > print LOG "Commencing maintenance\n"; > > my $pid = open3( 0, '>&LOG', 0, 'path-to-command' ); > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- o _ _ _ _o /\_ _ \\o (_)\__/o (_) _< \_ _>(_) (_)/<_ \_| \ _|/' \/ (_)>(_) (_) (_) (_) (_)' _\o_ http://zapatopi.net/afdb.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]