1752458 Members
6329 Online
108788 Solutions
New Discussion юеВ

Re: tar problem

 
SOLVED
Go to solution
pareshan
Regular Advisor

tar problem

I have tried to do tar and untar of files between remoter servers but its not working anyone can suggest me whether the way want is possible or not...

Being in server1, Im trying to to tar files from server2 and untar directly in server3 in one line. here the code i have tried.

ssh -l username 2ndservername tar -cf - /home/foldername|ssh -l usernrame 3rdservername " cd /home/tuxtnk/copied/ && tar -xvf -"

My another code is working which tar file in the server1 (i.e. from the current server) and untar in the server3 but i am trying to between 2 different remote machines from the script in the current machine.

tar -cf - /home/foldername|ssh -l usernrame 3rdservername " cd /home/tuxtnk/copied/ && tar -xvf -"

I will really appreciate the help
thanks in advance
10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: tar problem

Shalom,

Please check the response code on this command:

tar -cf - /home/foldername|ssh -l usernrame 3rdservername " cd /home/tuxtnk/copied/ && tar -xvf -"

Looks like a syntax issue to me.

maybe -xvf - xvf

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
pareshan
Regular Advisor

Re: tar problem

This is not syntax isse because the second one is working fine. i dont have any problem on that one. that was my typing mistake sorry for that but my problem is in the first script i have written
i.e.

ssh -l username 3rdservername tar -cf - /home/foldetotar|ssh -l username 2ndservername " cd /home/foldertountar && tar -xvf -"

The error I got is

Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh: Could not resolve hostname 2ndservername cd /home/foldertountar && tar -xvf : host nor service provided, or not known
James R. Ferguson
Acclaimed Contributor

Re: tar problem

Hi:

A chain like this works to reach "server-3" from "server-2" having been initiated on "server-1":

# ssh host2 "uname -a;hostname;ssh host3 uname -a;hostname"

Regards!

...JRF...
pareshan
Regular Advisor

Re: tar problem

Hi JRF

I dint get your solution. could you please explain it to me syntatically so that i can try in my terminal. I will really appreciate it

thanks alot
pareshan
James R. Ferguson
Acclaimed Contributor

Re: tar problem

Hi (again):

> I didnt get your solution. could you please explain it to me syntatically so that i can try in my terminal. I will really appreciate it


The point was that you are not piping anything as you tried to do, but rather are "hopping" server-to-server, and running something when you "land".

I think you need to 'scp' the tar archive in one step and then in another step un-tar the copied archive.

Regards!

...JRF...
pareshan
Regular Advisor

Re: tar problem

I got your point actually I thought the same way at first. In 2 steps i can do it. so that means there is now way that i can do it in one step??
James R. Ferguson
Acclaimed Contributor
Solution

Re: tar problem

Hi (again):

> so that means there is no[w] way that i can do it in one step??

Define "one step". How much do you want to cram on a commandline? Do yourself a favor and write a simple script in a file that you then launch just like any command.

Regards!

...JRF...
pareshan
Regular Advisor

Re: tar problem

Actually I am writting a script and this is just a small portion of it. My script is becoming bigger and bigger and I have to use this kind of commands several times thats why I was trying to find a way to make it short so that I can make it shorter. Anyway I really appreciate your response. I will try to be in contact with you because I know moving further again I will have problems much more important and complex than this one.
thank you very much JRF
James R. Ferguson
Acclaimed Contributor

Re: tar problem

Hi (again):

> My script is becoming bigger and bigger and I have to use this kind of commands several times thats why I was trying to find a way to make it short

That's why you write functions or subroutines and pass arguments to them.

Regards!

...JRF...