Extract tar archive on remote server in another directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extract tar archive on remote server in another directory
# 1  
Old 02-23-2015
Extract tar archive on remote server in another directory

HI All
Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything is working fine:

Code:
$( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' )



but when im trying extract the TAR content ( without base directory) to another location, command doesnt work(no untar or any error ) :

Code:
$( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name -C /path_2 --strip 1 ' )


Please advise what im doing wrong

Last edited by BACya; 02-23-2015 at 06:17 PM..
# 2  
Old 02-23-2015
Not sure it's the only culprit, but you missed a = after strip.

And, although your using code tags is appreciated, don't double post. Edit your mistakes in the first post.
# 3  
Old 02-25-2015
Thanks RudiC.

But the issue still exists and it doest matter if im using:
Code:
-C /path_2

or
Code:
--strip=1

separately or together , once im adding the flag the tar command not working.
(just tested it without the flags and archive extracted properly in same directory)

Can someone advice ??? please ...
# 4  
Old 02-25-2015
A bit strange. man tar :
Quote:
-C, --directory DIR
change to directory DIR
Does path_2 exist in the root directory? If really needed, you might need to escape the "/".
# 5  
Old 02-25-2015
I seem to remember that there's an order sensitivity in tar's "-C" option, leading me to avoid using it.
# 6  
Old 02-25-2015
either tar ... -C path2dir or using pax if available.
Here's a sample:
Code:
pax -rpe -f /tmp/samba.tar -s :^/samba:/newdir1/newdir2:g

# 7  
Old 02-25-2015
Code:
ssh -n <user>@<server> '
. ~/.profile >/dev/null 2>&1
copiedIVR_name=`ls -tr /path_1 | tail -1` &&
cd /path_2 &&
tar xvf /path_1/$copiedIVR_name
'

A command can fail - the && continues only if exit status is zero.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract tar archive on remote server in another directory

HI Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything working fine: $( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' ) but i have to ... (1 Reply)
Discussion started by: BACya
1 Replies

2. UNIX for Dummies Questions & Answers

Remote FTP Backup -Tar archive+ encrypt+ split to a remote ftp

I have a huge directoy(200+ gb) for backup. I want upload the tar file(split files) simultaneous to a remote ftp. (pipeline, stdout, stdin etc.) I don't want write a data to local hdd. I have a ssd hdd. thanks. this code doesn't work.( yes i know the problem is split command!) tar cvzf -... (8 Replies)
Discussion started by: tara123
8 Replies

3. Shell Programming and Scripting

Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to... (7 Replies)
Discussion started by: AIXfrog
7 Replies

4. UNIX for Dummies Questions & Answers

create tar archive without preserving directory structure?

I am adding some individual files to a tar archive and would like them to be added to the archive without any directory hierarchy, even though the files themselves exist in levels of hierarchy. Unfortunately, tar seems to always preserve the directory hierarchy when it adds the files. Here is... (2 Replies)
Discussion started by: Special_K
2 Replies

5. UNIX for Dummies Questions & Answers

choose what to extract from tar archive

Hello! I want to extract a choosen directory (and its contents) from a tar archive and i have tried what i believe is every option i could find in the manual. I think i have done it once before, but i don't remeber how. Could anyone please tell me how to do? (2 Replies)
Discussion started by: noratx
2 Replies

6. UNIX for Advanced & Expert Users

tar extract to different directory

Hi, I created a tar file of a directory dir1 from /tmp in the following way $pwd /tmp $tar -cvf dir1.tar dir1 (dir1 will have say file1) Now i want to extract it in the directory /tmp/dir2 so that the directory dir1 is also created and extracted... (1 Reply)
Discussion started by: ammu
1 Replies

7. UNIX for Dummies Questions & Answers

extract tar files without creating directory

I received a tar file of a directory with 50,000 files in it. Is it possible to extract the files in the tar file without first creating the directory? ie. Doing tar -xvf filename.tar extracts as follows: x directory/file1.txt x directory/file2.txt . . . I would like to avoid... (4 Replies)
Discussion started by: here2learn
4 Replies

8. UNIX for Dummies Questions & Answers

How to extract archive to a specified directory

Hi, I would like to extract the files from an archive which I have copied from a different server which has different file structures to my server. When I do a tar xvf archive_name, I get the error saying the file or directory cannot be found. How do I specify a desginated directory to... (4 Replies)
Discussion started by: john_trinh
4 Replies

9. UNIX for Advanced & Expert Users

extract a sub directory form a tar file

anyone know if it is possable to extract a subdirectory in a tar file. IE tarfile contains parent dir -sub dir A -sub dir B I want to extract sub dir B. (2 Replies)
Discussion started by: Optimus_P
2 Replies

10. UNIX for Dummies Questions & Answers

redirecting tar extract to another directory

Is it possible to redirect the output from 'tar xvf' to another directory? The taped tar image is extracting to my / dircetory - even though i'm running the command from /backups. The contents list of the tape shows files created from /livebackups/... Thanks Richard (7 Replies)
Discussion started by: colesy
7 Replies
Login or Register to Ask a Question