On Wed, 16 Mar 2005, Paul Ohashi wrote:

> I can't see enough to determine why your script is failing, but
> the four lines below work as expected:
> 
> #!/usr/local/bin/perl
> $logFile = '/home/paulo/mylog.log';
> $myCmd = 'ls -l';
> system ("$myCmd | tee -a $logFile");
> 
> Hope this helps...

Is there some reason that everyone has latched onto the system `tee` 
command rather than doing this in Perl?

The "tctee" program shown in _Perl Cookbook_ (either edition) shows how 
to do this directly in Perl. The program in question can be downloaded 
from the book's site (click on "examples")  --

    <http://www.oreilly.com/catalog/cookbook/>
    <http://www.oreilly.com/catalog/perlckbk2/>

 -- or from this Sourceforge page --

    <http://pleac.sourceforge.net/pleac_perl/filecontents.html#AEN487>

There's no clear reason to prefer an external program to do this job.



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to