The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Tar utility (untar a .tar file) on VxWorks uday_01 UNIX for Advanced & Expert Users 1 05-26-2008 06:13 AM
unable to UNTAR a file NIMISH AGARWAL UNIX and Linux Applications 6 05-08-2008 08:35 PM
untar to a specified file melanie_pfefer UNIX for Dummies Questions & Answers 3 11-27-2006 10:32 AM
Untar a TAR file at different location malaymaru UNIX for Dummies Questions & Answers 5 09-18-2006 05:59 PM
unTar a specific file from remote gelbvonn Shell Programming and Scripting 2 05-25-2006 12:59 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-27-2008
Registered User
 

Join Date: May 2008
Posts: 2
How do I untar file through an ssh session?

Hi All,

How do I untar (tar xvf) a file through an ssh session?

I have a tar file with "relative path names".
I scp the file to a remote host:/tmp - no prob.
But when I untar the file through ssh from a remote host
it puts it in my "home directory" under the relative path -
not in /tmp where I really want it to go.

Here it is:

$ set -o vi
$ tar tvf test.tar
drwxr-xr-x 992 205 0 May 23 15:14:44 2008 holdingArea/
drwxr-xr-x 992 205 0 May 23 15:14:42 2008 holdingArea/ccmig_1_00/
drwxrwxrwx 992 205 0 May 23 15:14:44 2008 holdingArea/stage/
drwxrwxrwx 992 205 0 May 23 15:14:54 2008 holdingArea/stage/ccmig_1_00/
drwxr-xr-x 992 205 0 May 23 15:14:53 2008 holdingArea/stage/ccmig_1_00/system/
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/system/system1.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/system/system2.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/system/system3.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/system/system4.txt
drwxr-xr-x 992 205 0 May 23 15:14:53 2008 holdingArea/stage/ccmig_1_00/utils/
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/utils/utils1.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/utils/utils2.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/utils/utils3.txt
-rwxrwxr-x 992 205 7 May 23 15:14:55 2008 holdingArea/stage/ccmig_1_00/utils/utils4.txt
drwxr-xr-x 992 205 0 May 23 15:14:54 2008 holdingArea/stage/ccmig_1_00/config/
drwxr-xr-x 992 205 0 May 23 15:14:54 2008 holdingArea/stage/ccmig_1_00/config/config1/
-rwxrwxr-x 992 205 7 May 23 15:14:56 2008 holdingArea/stage/ccmig_1_00/config/config1/config11.txt
-rwxrwxr-x 992 205 7 May 23 15:14:56 2008 holdingArea/stage/ccmig_1_00/config/config1/config12.txt
-rwxrwxr-x 992 205 7 May 23 15:14:56 2008 holdingArea/stage/ccmig_1_00/config/config1/config13.txt
-rwxrwxr-x 992 205 7 May 23 15:14:56 2008 holdingArea/stage/ccmig_1_00/config/config1/config14.txt
drwxr-xr-x 992 205 0 May 23 15:14:54 2008 holdingArea/stage/ccmig_1_00/config/config1/config2/
-rwxrwxr-x 992 205 7 May 23 15:14:56 2008 holdingArea/stage/ccmig_1_00/config/config1/config2/config21.txt
-rwxrwxr-x 992 205 7 May 23 15:14:57 2008 holdingArea/stage/ccmig_1_00/config/config1/config2/config31/config314.txt
. . . .
$ whoami
framrodjones
$ scp test.tar remotehost:/tmp
test.tar 100% 40KB 40.0KB/s 00:00
$
$ ssh remotehost tar xvf /tmp/test.tar
x holdingArea
x holdingArea/ccmig_1_00
x holdingArea/stage
x holdingArea/stage/ccmig_1_00
x holdingArea/stage/ccmig_1_00/system
x holdingArea/stage/ccmig_1_00/system/system1.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/system/system2.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/system/system3.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/system/system4.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/utils
x holdingArea/stage/ccmig_1_00/utils/utils1.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/utils/utils2.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/utils/utils3.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/utils/utils4.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config
x holdingArea/stage/ccmig_1_00/config/config1
x holdingArea/stage/ccmig_1_00/config/config1/config11.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config12.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config13.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config14.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config2
x holdingArea/stage/ccmig_1_00/config/config1/config2/config21.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config2/config22.txt, 7 bytes, 1 tape blocks
x holdingArea/stage/ccmig_1_00/config/config1/config2/config23.txt, 7 bytes, 1 tape blocks
. . . .
$

OK - looks good. But when I login to remotehost and cd /tmp there is
no holdingArea there.

If I cd ~framrodjones - bingo - the holdingArea is there.
But that's not where I want it. How to I untar the test.tar so that it installs
in the directory where I scp'd it?

Thanks, FramRodJones
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-27-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 674
Code:
ssh remotehost (cd /tmp ; tar xvf test.tar)
or
Code:
ssh remotehost "cd tmp ; tar xvf test.tar"
depending on your shell.


Better yet though, why not stream it? That way you don't need to scp it first.
Code:
cat test.tar | ssh remotehost "cd tmp ; tar xvf -"
Taking the example even further:
Code:
cd /where/the/original/data/is ; tar -cf - . | ssh remotehost "cd tmp ; tar xvf -"
Reply With Quote
  #3 (permalink)  
Old 05-28-2008
Registered User
 

Join Date: May 2008
Posts: 2
Quote:
Originally Posted by Smiling Dragon View Post
Code:
ssh remotehost (cd /tmp ; tar xvf test.tar)
or
Code:
ssh remotehost "cd tmp ; tar xvf test.tar"
depending on your shell.


Better yet though, why not stream it? That way you don't need to scp it first.
Code:
cat test.tar | ssh remotehost "cd tmp ; tar xvf -"
Taking the example even further:
Code:
cd /where/the/original/data/is ; tar -cf - . | ssh remotehost "cd tmp ; tar xvf -"

Totally cool.
I chose this: cat test.tar | ssh remotehost "cd tmp ; tar xvf -"

Works great! Thank you!
Reply With Quote
  #4 (permalink)  
Old 05-28-2008
Registered User
 

Join Date: May 2007
Posts: 26
hope you know when you ssh / telnet / rlogin as a specific user to a box, you are taken to that particular users home directory. In your case, you were taken to your home directory in the remore box and tar was extracting at the location you were at, while issuing the tar command
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0