Re: rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Sun, 25 Jan 2009 02:31:36 +0000
On 2009-01-23, Wayne wrote:
Bill Marcum wrote:
On 2009-01-23, Ekkard Gerlach <jack@xxxxxxx> wrote:
Hi,
somebody here a solution for writing the std-out (and err-out) to the
screen (terminal) *AND* to a file *AND* evaluate the exit code '$?' ?
example:
# rsync .... <source>... <target> | tee /tmp/somefile.txt 2>&1
In this example is the exitcode $? of rsync lost! If rsync remarks an
error then exit code is nonequal zero but the pipe to tee is *always*
true, so exit code is always zero!
Is the only way to preserve exit code $? the ">" redirection?
If you use bash, there is ${PIPESTATUS[*]}
Be careful with that solution; by default interactive
Bash shells use PROMPT_COMMAND to display a prompt,
No, they don't; they use $PS1.
By default, PROMPT_COMMAND is not set.
and last time I checked this reset PIPSTATUS and $?.
Not in bash 3.2 or 4.0, but it does in 2.05b.
(A script won't have that problem however.)
True.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- References:
- rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- From: Ekkard Gerlach
- Re: rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- From: Bill Marcum
- Re: rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- From: Wayne
- rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- Prev by Date: Re: screen capturing (gnome) mouse over events
- Next by Date: File redirection
- Previous by thread: Re: rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- Next by thread: Re: rsync, growisofs, ..: write log to terminal *and* file *and* evaluate exit status
- Index(es):
Relevant Pages
|