LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2009, 10:45 AM   #1
eric_torti
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Rep: Reputation: 0
tar hangs after extracting from pipe


Hello,

I'm making some backup files with predefined sizes for cd storage with the folowing command.

# tar cvPf - /home | gzip v - | split -b 600m - backup.tar.gz.*

This generates a number of files like
backup.tar.gz.aa
backup.tar.gz.ab
backup.tar.gz.ac
... and so on.

Problem is, when I extract from these files with the command

# cat backup.tar.gz.* - | tar xzvPf -

Everything works great, except that, after extracting the files, the prompt hangs. So I have to Ctrl+C to get it back.

I've experimented with tar parameters, but no success so far.

Any help will be greatly appreciated.

System is: Linux version 2.6.18-6-686 (Debian 2.6.18.dfsg.1-23etch1)

Thanks.

Eric
 
Old 07-07-2009, 01:55 PM   #2
whirler
LQ Newbie
 
Registered: Nov 2008
Posts: 9

Rep: Reputation: 0
It's been a little while since I've written any shell scripts but would it work to use something like "exit" or "break" to force the script to end after your files are extracted?
 
Old 07-08-2009, 03:00 PM   #3
eric_torti
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Curiously it doesn't work.

When I do:

# cat backup.tar.gz.* - | tar xzvPf - && break

or

# cat backup.tar.gz.* - | tar xzvPf - && exit

It just hangs as if exit or break were not there. So I infer that, as the tar command doesn't return the prompt, exit or break are actualy never reached.

On the other hand, when I try:

# cat backup.tar.gz.* - | tar xzvPf - | break

The prompt displays a warning saying that break must be used solely on loops.

And:

# cat backup.tar.gz.* - | tar xzvPf - | exit

The tar process is inerrupted prematurely and not all tared files are extracted.

When I try:

# cat backup.tar.gz.* - | tar xzvPf - > exit

Prompt hangs as if > exit were not even there.

So..

I think I'm running out of options :]

Thank you for the reply, though.
 
Old 07-08-2009, 08:27 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
tar won't know where the end of file is because you split the output.
You could try sorting the list before input, so tar is extracting in the right order.
You could concatenate the files first, before extraction.

I think there are tools that will do all this for you instead of tar.
See the page here http://www.debianhelp.co.uk/backuptools1.htm
 
Old 07-08-2009, 09:34 PM   #5
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 516

Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by eric_torti View Post
# cat backup.tar.gz.* - | tar xzvPf - && break
From the cat man page:
Quote:
With no FILE, or when FILE is -, read standard input
Remove the "-" and it should work.
Code:
# cat backup.tar.gz.* | tar xzvPf -
Your cat command is waiting for input from the keyboard (stdin).
 
Old 07-10-2009, 02:43 PM   #6
eric_torti
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
tar won't know where the end of file is because you split the output.
You could try sorting the list before input, so tar is extracting in the right order.
You could concatenate the files first, before extraction.

I think there are tools that will do all this for you instead of tar.
See the page here http://www.debianhelp.co.uk/backuptools1.htm
Hello, chrism01, thank you for the references. I'll have a look at them.
 
Old 07-10-2009, 02:53 PM   #7
eric_torti
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by norobro View Post
From the cat man page:
Remove the "-" and it should work.
Code:
# cat backup.tar.gz.* | tar xzvPf -
Your cat command is waiting for input from the keyboard (stdin).
Hi, norobro, I've tryed the xzvP parameters and tar hangs as well.

The solution I found was adding nohup to the beginning of the command, as in:

# nohup cat test.tar.gz.a* - | tar xzvP

And I got away with a warning:

gzip: stdin: decompression OK, trailing garbage ignored
tar: Child returned status 2
tar: Saída por erro atrasada pelos erros anteriores
(translating last line from portuguese)
tar: Error exit delayed by previous errors

Thank you for your help.
 
Old 07-10-2009, 03:00 PM   #8
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 516

Rep: Reputation: 177Reputation: 177
I was referring to the first "-".
Code:
cat backup.tar.gz.* - | tar xzvPf -
Your cat command is piping all of your tar.gz files to tar then the dash is causing cat to wait for input from stdin.
 
Old 07-11-2009, 10:01 AM   #9
eric_torti
LQ Newbie
 
Registered: Jul 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by norobro View Post
I was referring to the first "-".
Code:
cat backup.tar.gz.* - | tar xzvPf -
Your cat command is piping all of your tar.gz files to tar then the dash is causing cat to wait for input from stdin.
Thanks, norobro, you are absolutely right.

Working command is

# cat backup.tar.gz.* | tar xzvP

or

# cat backup.tar.gz.* | tar xzvPf -

Being that the first makes more sense to me.

Thank you.

Last edited by eric_torti; 07-11-2009 at 10:03 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
After extracting a tar...is tar useless? glenn69 Linux - Newbie 6 04-23-2004 10:04 PM
Extracting multivolume tar Cichlid Linux - Software 3 12-21-2003 02:54 AM
extracting -filename.tar.gz- zokter Linux - Newbie 3 06-29-2003 07:18 AM


All times are GMT -5. The time now is 11:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration