Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Tee all output to log file?



Reply to message «Tee all output to log file?», 
sent 02:41:26 02 February 2011, Wednesday
by Benjamin R. Haskell:

> Is there something straightforward that I'm overlooking?  Is there a
> commonly used utility for this?  (`script` comes to mind, but I recall
> klunkiness when trying it in the past.)
If you don't like script, maybe you should try screen:

    (( $+logfile )) && \
        exec screen -L -c =(echo "logfile $logfile") -m -S script-$0 $0 $@

(probably needs some escaping of $logfile).

Does anybody know, why it does not work when I start screen in detached mode?

Original message:
> For scripting purposes I occasionally want a way to both record and
> display all the output of a script.  On several occasions now, I've
> looked through the output redirection section of the manual, but I never
> come up with quite what I'm looking for.
> 
> Essentially, when I want this, I usually want something like:
> 
> #!/bin/zsh
> (( $+logfile )) && exec |& tee $logfile
> 
> Boiled down even further, it's really just this I'm looking for:
> exec |& tee logfile
> 
> Is there something straightforward that I'm overlooking?  Is there a
> commonly used utility for this?  (`script` comes to mind, but I recall
> klunkiness when trying it in the past.)

Attachment: signature.asc
Description: This is a digitally signed message part.



Messages sorted by: Reverse Date, Date, Thread, Author