From owner-freebsd-questions Wed Feb 14 5:34:54 2001 Delivered-To: freebsd-questions@freebsd.org Received: from bcfw1d.bridge.com (mailgate1b.ext.bridge.com [167.76.159.31]) by hub.freebsd.org (Postfix) with ESMTP id D9FDD37B401 for ; Wed, 14 Feb 2001 05:34:49 -0800 (PST) Received: (from uucp@localhost) by bcfw1d.bridge.com (8.10.2/8.10.2) id f1EDZoA26410; Wed, 14 Feb 2001 07:35:51 -0600 (CST) Received: from unknown(167.76.56.34) by bcfw1d.bridge.com via smap (V5.5) id xma026287; Wed, 14 Feb 01 07:35:32 -0600 Received: from mnmailhost (mnmailhost.bridge.com [167.76.155.14]) by mail1srv.bridge.com (8.8.8/8.7.3) with SMTP id HAA20527; Wed, 14 Feb 2001 07:34:28 -0600 (CST) Received: from 89-7 by mnmailhost (SMI-8.6/SMI-4.1) id IAA08564; Wed, 14 Feb 2001 08:34:25 -0500 To: freebsd-questions@FreeBSD.ORG Subject: Re: redirecting output References: From: Tim Ayers Date: 14 Feb 2001 07:34:25 -0600 In-Reply-To: Peter Brezny's message of "Tue, 13 Feb 2001 15:31:21 -0500 (EST)" Message-ID: Lines: 36 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >>>>> "P" == Peter Brezny writes: P> I'm trying to redirect output from a process when i use this P> virtual2# nice ( /usr/bin/tar cvflj - /usr/local/scripts > P> /bkup/archive/`date +%y%m%d`-test.bz P> 2 ) 2 > & 1 > /bkup/archive/test.log P> It tells me i've got an ambiguous output redirect... It looks like you are tar'ing up an archive and want to capture the output from the command to a log file, right? And the "2 > & 1" implies an sh variant, right? Try this nice /usr/bin/tar cvflj /bkup/archive/`date +%y%m%d`-test.bz \ > /bkup/archive/test.log 2>&1 You don't need to send tar to stdout and then capture it. "tar cf - * > foo.tar" should be completely equivalent to "tar cf foo.tar *" without the complication of another redirect. It also removes the need for the subshell which isn't helping anything. Also note when you are redirecting stderr to stdout (2>&1) _and_ redirecting stdout somewhere, you need to do them in the opposite order of intuition. That is because the 2>&1 works by cloning stdout and attaching it to stderr. If you do 2>&1 first, it clones stdout, which is the console, so you end up right where you started. But if you do the "> myfile.txt" first, then 2>&1 clones the "> myfile.txt" redirection and everything works hunky dory. HTH and Hope you have a very nice day, :-) Tim Ayers (tayers@bridge.com) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message