Dan, Olof, all,

> I need to pipe the tar command into ssh (or whatever)
> so the file is created on the remote server.
> 
> someone said to use:
>
> tar cvf - | ssh remotehost | dd of=/home/dir/file | tar xvf -
>
> but somehow I don't think that works either.

No, because your tar syntax is wrong, your piping is wrong, and your
I/O redirection is wrong. Wow. That's a lot of wrong...

View this explanation of "why?" with a fixed width font:

> tar cvf - | ssh remotehost | dd of=/home/dir/file | tar xvf -

  |                          | |                    |
  |                          | |                    |_ You're piping the stdout
  |                          | |                       of dd, which is nothing,
  |                          | |                       to tar.
  |                          | |
  |                          | |_ If you didn't have the previous pipe here,
  |                          |    you would be writing the tar output to a file
  |                          |    on the remote host. Now you are writing the
  |                          |    stdout of ssh (= nothing) to a local file.
  |                          |
  |                          |_ You're piping the stdout of ssh, not the tar
  |                             output.
  |
  |_ You need to specify a file or directory that you want to put in. Otherwise
     GNU tar will fail ("tar: Cowardly refusing to create an empty archive
     Try `tar --help' for more information.") as will the "standard" one (on
     HP-UX, I get "Attempt to create archive of no files. Nothing dumped.")

This works:

tar cvf - [ files or directories ] | ssh remotehost tar xfv -

-- 
Atro Tossavainen (Mr.)               / The Institute of Biotechnology at
Systems Analyst, Techno-Amish &     / the University of Helsinki, Finland,
+358-9-19158939  UNIX Dinosaur     / employs me, but my opinions are my own.
< URL : http : / / www . iki . fi / atro . tossavainen / >

Reply via email to