0

The following block executes fine in script but gives exit code 1. But when i run this at shell prompt executes fine with message

tar: Removing leading `/' from member names

and gives exit code 0. Why it is behaving differently. How to fix this to avoid exit code 1 when run using script.

tar -czf $tracedir/dbtrace.tar.gz $tracedir

status=$?

if [ $status -ne 0 ]; then
    echo "The error code is---"$status >> output.log
fi

How to avoid exit code 1 when run using script ?

user2439245
  • 89
  • 1
  • 2
  • 9
  • Possible duplicate of [tar: Removing leading \`/' from member names](https://unix.stackexchange.com/questions/59243/tar-removing-leading-from-member-names) – Inian May 30 '19 at 05:20
  • In both cases it works fine, but i want to avoid exit code 1 when i run using script – user2439245 May 30 '19 at 05:27
  • In my Debian the exit code `1` from `tar` (GNU tar 1.29) is special. It means "some files were changed while being archived"; it may also come from a subprocess (e.g. `gzip`). Did you receive any error message? What was it? Side note: [quote the variables](https://unix.stackexchange.com/q/131766/108618). – Kamil Maciorowski May 30 '19 at 06:37
  • Thank you, there are no other errors. – user2439245 May 31 '19 at 03:51

0 Answers0