in reply to exit value in tar command

To simplify detecting success or failure, I just echoed success or failure. I also made some other corrections to your attempt:

I used the existence of the target directory as a simple way to test the failure case (how are you testing the failure case?). Worked for me as shown below:
$ pwd /home/knob $ cat t1.sh #!/bin/ksh if tar cf - . | (cd /var/tmp/dump && tar xf -); then echo "success" else echo "failure" fi $ rm -fr /var/tmp/dump $ ./t1.sh ./t1.sh[2]: /var/tmp/dump: not found. failure $ mkdir /var/tmp/dump $ ./t1.sh success $ ls -l total 8 -rwxrwxrwx 1 knob devel 108 30 Aug 17:51 t1.sh $ ls -l /var/tmp/dump total 8 -rwxrwxr-x 1 knob devel 108 30 Aug 17:51 t1.sh

Note that, for simplicity, I created a scratch directory (/home/knob above) containing just the test script itself t1.sh and cd'ed into this directory -- so this is the directory that is copied. If yours does not work, post the output of running your command (as I did above).