Linked Questions

11
votes
3answers
5k views

How can I pipe output to another process, but retain the error state of the first process? [duplicate]

Possible Duplicate: Get exit code of process that's piped to another I am using the following command line (in a makefile) to pipe the verbose error messages from my compiler through a perl ...
8
votes
2answers
18k views

How do I capture the return status and use tee at the same time in korn shell? [duplicate]

Consider Source code: 1. Parent.sh #!/usr/bin/ksh # No tee ksh Child.sh; exit_status=$?; echo "Exit status: ${exit_status}" # Using tee ksh Child.sh | tee -a log.txt; exit_status=$?; echo "Exit ...
4
votes
2answers
740 views

How to capture the exit status of a non-final command in a pipeline? [duplicate]

I want to capture the exit status of a command that takes place somewhere in a pipeline before the last position. For example, if the pipeline is something like command_1 ... | command_2 ... | ...
1
vote
2answers
2k views

exit code of the command **before** last? [duplicate]

I'm running a script within a script, release.sh and caller.sh (caller.sh calls release.sh). Both are bash. release.sh contains a bunch of conditions with 'exit 1' for errors. caller.sh contains a ...
1
vote
1answer
2k views

Check for failure of piped command [duplicate]

Possible Duplicate: Get exit code of process that's piped to another If I pipe the output of one command into another, is there a way for me to check explicitly whether the first command ...
2
votes
1answer
304 views

How to get exit status of a particular command in a pipeline? [duplicate]

I am running this while loop in a script to take mysqldump and compress it, but I want to exit the script if the table doesn't exist. Below is what I have tried. while read TABLES; do sudo ...
4
votes
1answer
624 views

returncode of command in a pipline [duplicate]

The following script runs on Solaris using /bin/ksh and on Linux using /bin/sh cmd | tee -a cmd.log | tail exit $? The output of cmd is saved in a file cmd.log and the last lines are displayed on ...
0
votes
1answer
678 views

Get exit code from preceding command before pipe [duplicate]

I have this: node ${SUMAN_RUNNABLE} | tee -a run.sh.log EXIT_CODE=$?; but it looks like the exit code is always 0 because tee is providing the code not the node executable. Is there a way to ...
8
votes
0answers
248 views

how to get exit status from the command before the last [duplicate]

I have solaris machine ( solaris 10 ) please Look on the following simple commands (haconf -makerw | grep -iq "Cluster already writable") # haconf -makerw VCS WARNING V-16-1-10364 Cluster ...
1
vote
0answers
58 views

How to capture “$?” before tee smashes it? [duplicate]

I've got a test script that repeatedly builds a library under different configurations. It also tee's the output for postmortem failures: $MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$...
1
vote
0answers
23 views

Test execution output of a command before a pipe [duplicate]

I would like to test the execution of a php script that redirect its stdout and stderr to a file with tee. php /path/to/script --param 2>&1 | tee -a /path/to/log if ( test $? -ne 0 ); then ...
0
votes
0answers
23 views

How can I catch command status code and throw error before tee? [duplicate]

I want to catch (and throw error) before tee command. #!/usr/bin/env bash set -xe serverless | tee /tmp/output.txt However serverless command fails, tee returns non-error status code. How can I ...
262
votes
6answers
25k views

What's the difference between $(stuff) and `stuff`?

There are two syntaxes for command substitution: with dollar-parentheses and with backticks. Running top -p $(pidof init) and top -p `pidof init` gives the same output. Are these two ways of doing the ...
127
votes
7answers
205k views

tar: Removing leading `/' from member names

root@server # tar fcz bkup.tar.gz /home/foo/ tar: Removing leading `/' from member names How can I solve this problem and keep the / on file names ?
8
votes
4answers
3k views

Bash exit status used with PIPE

I am trying to understand how exit status is communicated when a pipe is used. Suppose I am using which to locate a non-existent program: which lss echo $? 1 Since which failed to locate lss I got ...

15 30 50 per page