![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use tee with stdout and stderr? | siegfried | Shell Programming and Scripting | 3 | 01-14-2009 10:07 PM |
| Redirecting STDERR message to STDOUT & file at same time | vikashtulsiyan | Shell Programming and Scripting | 10 | 04-09-2008 02:34 PM |
| precedence of stderr and stdout | new2ss | Shell Programming and Scripting | 1 | 06-08-2006 11:03 PM |
| Redirect stdout & stderr and append to a file | Santi | Shell Programming and Scripting | 2 | 01-02-2006 07:58 PM |
| STDOUT and STDERR going to a system log | longyie904 | Shell Programming and Scripting | 1 | 09-11-2002 11:42 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
stderr & stdout to a file and the right exit code
Hi all,
I need to redirect stdout and stderr to a file in a ksh shell. That's not a problem. But I need also the correct exit code for the executed command. In the example below I redirect correctly the stdout & stderr to a file, but I have the exit code of tee command and not for the mv command. The script: #!/bin/ksh ( mv files.log file.log EXITSTATUS=$? if [ ${EXITSTATUS} -ne 0 ] then exit ${EXITSTATUS} fi ) 3>&1 1>&2 2>&3 |tee -a logfile echo $? echo "exit code" $EXISTATUS here is the output: mv: rename files.log to file.log: No such file or directory 0 exit code here is the logfile: mv: rename files.log to file.log: No such file or directory Please, could anyone help me? Thanks, bye |
|
||||
|
Just wondering if any one can help me understand how the below bolded code works.
Quote:
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|