The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 09:13 AM
unable to UNTAR a file NIMISH AGARWAL UNIX and Linux Applications 6 05-08-2008 11:35 PM
untar to a specified file melanie_pfefer UNIX for Dummies Questions & Answers 3 11-27-2006 02:32 PM
Untar a TAR file at different location malaymaru UNIX for Dummies Questions & Answers 5 09-18-2006 08:59 PM
unTar a specific file from remote gelbvonn Shell Programming and Scripting 2 05-25-2006 03:59 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 05-27-2008
Joe McCaughan Joe McCaughan is offline
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
  #2 (permalink)  
Old 05-28-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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 -"
  #3 (permalink)  
Old 05-28-2008
Joe McCaughan Joe McCaughan is offline
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!
  #4 (permalink)  
Old 05-28-2008
hercu hercu is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0