Stephen Liu wrote:
ssh [EMAIL PROTECTED] "cd /path/to/folder ; tar zc ." | tar zxx

It works, "zx" only. What is the function of "space" and "." after "tar zc"?

Yes, sorry.. zx is correct, not zxx. Blame the coffee :)


When compressing, if tar isn't compressing stdin, it needs to be told what to compress.
'.' specifies the current directory (on the remote host), which we have just changed to with cd.


If I expect to untar the tarball to a selected folder, instead of changing to the folder first to issue the command, can following command do the job

$ ssh [EMAIL PROTECTED] "cd /path/to/folder(MachineB) ; tar zc ." | "cd /path/to/folder(MachineA) ; tar zx"

I'm not sure it will, because 'cd' will then get stdin piped to it, and not to tar. I'll test...


ok, the problem with your command is that bash does not see "" as a command, and so won't execute:

"cd /path/to/folder(MachineA) ; tar zx"

Instead, you must run those commands in a subshell, like this:

$ ssh [EMAIL PROTECTED] "cd /path/to/folder(MachineB) ; tar zc ." | ( cd /path/to/folder(MachineA) ; tar zx )

ie. brackets instead of double quotes.

That worked for me :)

MAL


-- [EMAIL PROTECTED] mailing list



Reply via email to