|
|
ksh script, exit status and pipe
I want to execute a command, redirect stderr and tee stdout
e.g.
tar ... 2>foo.err | tee foo.log
however I also want to capture the exit status of the first command
tar ... 2>foo.err | tee foo.log
exitstatus = $?
simply gets the exit status of tee of course
tar ... || exitstatus=$? 2>foo.err | tee foo.log
always sets exitstatus to zero, looks like I need to establish some
precedence but brackets don't seem to help.
Is there an idiom for this?
Maybe I should hide the tar in a function?
Apologies if the above is a FAQ, I've RTFM where M = "Learning the Korn
Shell" and "Unix Power Tools", I'm none the wiser (though opening the
latter is always good for a half hour off-topic diversion).
|
|
0
|
|
|
|
Reply
|
Ian
|
8/25/2004 11:00:44 AM |
|
2004-08-25, 11:00(+00), Ian Wilson:
> I want to execute a command, redirect stderr and tee stdout
> e.g.
> tar ... 2>foo.err | tee foo.log
>
> however I also want to capture the exit status of the first command
[...]
See question 13 of the comp.unix.shell FAQ:
http://home.comcast.net/~j.p.h/cus-faq.html#M
--
Stephane
|
|
0
|
|
|
|
Reply
|
Stephane
|
8/25/2004 12:49:53 PM
|
|
|
1 Replies
617 Views
(page loaded in 0.082 seconds)
Similiar Articles: ksh debugging - comp.unix.solarisksh script, exit status and pipe - comp.unix.admin ksh or sed search & replace - comp.unix.programmer ksh script, exit status and pipe - comp.unix.admin ksh or sed search ... Test regex in KSH - comp.unix.shellksh script, exit status and pipe - comp.unix.admin Test regex in KSH - comp.unix.shell... 1-9][0-9]*|0)$" if [[ $? -eq 0 ]] then return ${__EXIT_STATUS_SUCCESS ... error while executing ksh script - comp.unix.shellksh script, exit status and pipe - comp.unix.admin ksh script, exit status and pipe - comp.unix.admin I want to execute a command ... remain at 0 as long as the ... sys ... How to early exit a script - comp.soft-sys.matlabksh script, exit status and pipe - comp.unix.admin How to early exit a script - comp.soft-sys.matlab How to early exit a script - comp.soft-sys.matlab... I want to run a binary from inside a ksh script - comp.unix ...ksh script, exit status and pipe - comp.unix.admin How to early exit a script - comp.soft-sys.matlab ksh script ... get the status from scripts running in the background ... Two-way pipe on an awk process - comp.lang.awkksh script, exit status and pipe - comp.unix.admin exec in AWK - comp.lang.awk... the command cmd-line, and return the exit status. ... How to pipe in an input list of ... how to get the status from scripts running in the background ...... wait until they are done 3. get the exit status 4. If ... I want to run a binary from inside a ksh script - comp.unix ..... soft-sys.matlab ksh script ... get the status ... How to code MatLab script to utilize GPU - comp.soft-sys.matlab ...... exit a script - comp.soft-sys.matlab How to early exit a script - comp.soft-sys.matlab... How to early exit a script - comp.soft-sys.matlab ksh script ... get the status ... how to kill all child when parent exits - comp.unix.programmer ...To avoid that you could create a > pipe in the ... PID of child */ pid_t retval; int status; /* exit status ... child - The UNIX and Linux Forums #!/bin/ksh # This script ... Execute command line program and capture output - comp.lang.rexx ...... Exec("ping www.rexxla.org") do while oExec~Status = 0 ... strError = oExec~StdErr~ReadAll Lee, Running the script ... AtEndOfStream = 0 say oExec~StdOut~ReadLine end exit ksh script, exit status and pipe - Linux / Unix AdministrationI want to execute a command, redirect stderr and tee stdout e.g. tar ... 2>foo.err | tee foo.log however I also want to capture the exit status of the first command ... KSH script BASICS - Wellcome Trust Centre for Human Genetics - HomePipes Coprocesses Read Input from User and from ... To make a ksh script (which is a ksh program) crate ... the script. It has an exit status but cannot return a value like a c ... 7/30/2012 2:54:19 PM
|
|
|
|
|
|
|
|
|