Bypassing error in tar


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bypassing error in tar
# 1  
Old 02-19-2008
Bypassing error in tar

I am tarring up a directory and then deleting the contents. I get a message that the file changed as tar was reading it, then my script fails on an error.

tar: /workdir/SRD.out.20080216: file changed as we read it
tar: Error exit delayed from previous errors

tar command failed, nothing archived - RC=0... message from my script.

The return code appears to be zero, but my script is not catching it and fails at that point without getting to the statement to delete the files. Any idea what I am doing wrong?

if ls $WORKDIR/* >/dev/null 2>&1; then
tar cvf $ARCH/logs.tar $WORKDIR
else
echo "No files to Archive"; exit 0;
fi
if [ "$?" -ge 1 ]; then echo "tar command failed, nothing archived - RC=$?..."; exit $?; fi
rm -f $WORKDIR/*
# 2  
Old 02-22-2008
Code:
$ cat bogus
#! /usr/bin/ksh

false
echo $?
echo $?


false
if [ $? -ge 1 ] ; then echo but now the code is $? ; fi
$ ./bogus
1
0
but now the code is 0
$

$? is not the exit status of the last command you care about. It is the exit status of the last command. If you do anything except a comment $? may change. The [ in the if statement is a command. You use [ to test the tar command's exit status, then you display the [ command's exit status. Always do stuff like:
tar_status=$?
immediately after the tar command and then test and display the saved version.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Do not allow bypassing users .profile

Hello, I find out that there is a way from putty to pass a command to your shell when trying to log in to a server and bypass .profile. Actually you can do this if you open a bash shell. The command to bypass .profile is the following: ssh -t hostname "bash --noprofile" Is there a way to... (32 Replies)
Discussion started by: omonoiatis9
32 Replies

2. Shell Programming and Scripting

Remoting sudo commands & bypassing bashrc

What I want to do is not unique, except that our environment has a twist. I want to ssh to a remote server and issue a sudo command to run a script. This isn't working, but you'll get the gist.# ssh remotehost sudo -i -u oracle script.bashThe sudo to oracle is fine. The script.bash sets up the... (4 Replies)
Discussion started by: JustaDude
4 Replies

3. IP Networking

Bypassing My Company Firewall!

Hi! My organization has put a Firewall which eat up a lot of important data access. So I came to know about SSH Tunneling to bypass the Firewall. I will have to setup a free access SSH server to tunnel data access through PUTTY or OpenSSH. The problem is that I don't know about any free... (1 Reply)
Discussion started by: nixhead
1 Replies

4. UNIX for Advanced & Expert Users

Bypassing blocking of websites...

So my workplace uses websense to block certain websites. I read while researching firesheep, that you can somehow bypass that by creating a proxy, and thus: #1 protect yourself from people using firesheep (if using unsecure hot-spot) and #2 or visit un-approved websites at work. I... (1 Reply)
Discussion started by: zixzix01
1 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. AIX

"ksh -" as login shell bypassing .profile

Hi all, I am currently trying to tell /bin/ksh to behave like a login shell. I am invoking it from an interactive shell. In the documentation is stated, that calling it with exec ksh - it should behave like a login shell, work 1st on /etc/profile, ~/.profile and so on. I tried that with... (0 Replies)
Discussion started by: zaxxon
0 Replies

7. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

8. Linux

tar error exit delayed form pervious error

Hi when use "tar cpvzf /dev/st0 --exclude=/proc --exclude-/lost+found --exclude=/mnt --exclude=/media --exclude=/sys /" to tape, get the following message "tar: error exit delayed form pervious error", What is the mean ? Please suggest some solution for these errors. thx (1 Reply)
Discussion started by: chayato
1 Replies

9. Solaris

TAR error

When I tried to decompress using TAR the following error was popped up.. tar: blocksize = 0 ..Can anyone tell me wht this means and how to rectify this error... (3 Replies)
Discussion started by: hemin_pm
3 Replies
Login or Register to Ask a Question