extract tarball across network?

Hello all,i have a tar file in machine A and i want to ftp/scp the file to machine B as the extracted copy.Example: aaa.tar in machine A shuld get copied to machine B as just aaa(means the untar'd content)is it possible, if yes how?
[268 byte] By [nagarajan] at [2007-11-25 23:39:53]
# 1

There's no program I'm aware of that can take the tar file and autoextract on the remote machine as a single step. Possible workarounds:

Copy file and extract on remote machine:

[A]% ssh user@B "cd /target && tar xf -" < aaa.tar

Extract file locally and copy:

[A]% mkdir tmp; cd tmp ; tar xf ../aaa.tar ; scp -rp . user@B:/target ; cd .. ; rm -rf tmp

Darren_Dunham at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 2
I've created a taball 'on the fly' never had a reason to do the reverseput "| tar cf - ." filename.tarno reason why you can't put "| tar xvf-. " filename.tar or some other variant.
richpierson at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 3
> Extract file locally and copy:> [A]% mkdir tmp; cd tmp ; tar xf ../aaa.tar ;> scp -rp . user@B:/target ; cd .. ; rm -rf tmp> Will this extract the file locally and copy to a remote site as and when is getting extracted?
nagarajan at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 4

> I've created a taball 'on the fly' never had a reason

> to do the reverse

>

> put "| tar cf - ." filename.tar

>

> no reason why you can't put "| tar xvf-. "

> filename.tar or some other variant.

Yes there's a big reason. Unlike 'tar c', 'tar x' writes to a filesystem, not to stdout or a single file (because it's potentially creating several files). You can't just pipe the output into ftp or anything else. The ftp/scp at the other end has to create all those files, and this method won't do it.

--

Darren

Darren_Dunham at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 5

> > Extract file locally and copy:

> > [A]% mkdir tmp; cd tmp ; tar xf ../aaa.tar ;

> > scp -rp . user@B:/target ; cd .. ; rm -rf tmp

> >

> Will this extract the file locally and copy to a

> remote site as and when is getting extracted?

I'm afraid I can't understand the question.

If you're asking about timestamps, then it'll try to preserve them, but you might want to stick a 'p' on the tar options.

--

Darren

Darren_Dunham at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 6

There are two solutions for your situation.

Untar the file locally to an empty directory and then have a script read the names of the files that were extracted and feed them to scp to complete the transfers.

Option two. Scp the tar file to the other machine. On the other machine setup a cron entry to untar the file and then move the files to their final destination.

alan

alan_pae at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...
# 7

> Example: aaa.tar in machine A shuld get copied to

> machine B as just aaa(means the untar'd content)

>

> is it possible, if yes how?

Why do I get the feeling you're trying to make us do your homework? Probably because I've seen some other threads dealing with the same issue but using other tools (ufsdump comes to mind).

Anyway, since others presented working solutions already I guess I might as well join in.

ssh <machineA> "cat aaa.tar" | tar xvf -

is IMO the easiest and cleanest method to do this. Do make sure you're in the right directory.

LionO at 2007-7-5 18:47:49 > top of Java-index,General,Talk to the Sysop...