0

I would like to pass the output of a tar command and multiple commands which handle the tar stream over ssh ... something like this

tar -zcf - foo | ssh $host << EOF
tar -xf -
do-something-with-foo
do-other-things
EOF

doesn't work but is this somehow possible?

1
  • this one here does the trick Commented Jun 18, 2015 at 9:34

1 Answer 1

1

Wrap everything up in a generated script that you pass to the remote host.

{
        echo 'uudecode -o- <<EOT | tar -xzf-'
        tar -czf- foo | uuencode -m foo
        echo EOT
        echo do-something-with-foo
        echo do-other-things

} | ssh -T $host

The echo output will be run on the remote host, the tar | uuencode runs locally. The purpose of the uuencode is so that we can wrap the output into a heredoc on the remote end, bypassing the need for severe file descriptor juggling.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this works so fare. Personally I like the 2nd version in the linked SO answer a bit more since it doesn't mix the two inputs and doesn't require a extra decode/encode on the tar stream.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.