From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6684 invoked by alias); 2 Feb 2011 17:28:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28691 Received: (qmail 308 invoked from network); 2 Feb 2011 17:28:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Wed, 2 Feb 2011 12:28:13 -0500 (EST) From: "Benjamin R. Haskell" To: ZyX cc: zsh-workers@zsh.org Subject: Re: Tee all output to log file? In-Reply-To: <201102020804.29094@-zyx> Message-ID: References: <201102020804.29094@-zyx> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463810530-759185321-1296667717=:2792" ---1463810530-759185321-1296667717=:2792 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Wed, 2 Feb 2011, ZyX wrote: > 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 $@ I find `screen` even more annoying than `script` for scripting purposes, wonderful though it is for interactive use. I really just want the redirection, not the many extra features that `screen` adds. Adding > Does anybody know, why it does not work when I start screen in detached mode? Cf. above annoyance. For doing something with Vim under Apache (using :TOhtml), I recently resorted to this hackery: screen -q -d -m -S $sessionname vim -u NONE -N +'so $scriptname' (Then, loop, waiting for one of: 1: the Vim script to touch a marker file that indicated completion 2: a specified timeout, in case something errored out, preventing a clean Vim exit ) screen -X -S $sessionname quit Despite my annoyance (I'm easily annoyed), I tried your above suggestion. It didn't capture stderr, so I added a flag that logging was in progress and added a redirect for it (also added '-q' to the `screen` commands): (( $+logfile && ! $+doinglogging )) \ && exec env doinglogging=true screen -L -c =(echo "logfile $logfile") -q -m -S script-$0 $0 $@ (( $+doinglogging )) && exec 2>&1 Seems okay for what I'm doing. Thanks, Ben ---1463810530-759185321-1296667717=:2792--