Linked Questions

11
votes
3answers
6k 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
20k 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
1k 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 ... | ...
2
votes
2answers
3k 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 ...
5
votes
2answers
49 views

Use ts without losing exit value [duplicate]

I have a build script that executes a long command that produces lots of output which went like this: ./compile In order to troubleshoot compilation performance, I want to use ts (from moreutils) ...
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
389 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 ...
0
votes
1answer
1k 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 ...
4
votes
1answer
775 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 ...
8
votes
0answers
258 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
64 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
24 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
14 views

How do I preserve the return status of the a command in a chain of piped commands? [duplicate]

Suppose I have a command a 2>&1 | grep -v 'stuff' | grep . I want to preserve the exit status of a while being able to filter out irrelevant lines (pseudo errors) that I don't want spamming ...
271
votes
6answers
30k 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 ...
158
votes
8answers
262k 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 ?

15 30 50 per page