Score:0

How to stream tar archive using plink?

in flag

I'd like to stream a .tar archive from a Windows machine using PowerShell to a Linux machine and extract the archive from the stream. PowerShell pushes archive content to stdout and plink.exe stream content to receiving command line's stdin.

I've come up with the following command.

Get-Content file.tar | & plink.exe -C -agent "remote_host" "tar xf -"

However, the tar command does recognize the file's content only partially. What I'm missing or is there a better solution for the problem?

Error message:

tar: Skipping to next header
tar: Exiting with failure status due to previous errors

in flag
Please post your solution as an answer instead of editing it into your question.
Score:0
in flag

Apparently, this is an encoding issue. By default, Get-Content returns file content as an encoded string but tar expects binary stream. The solution would be to encode the binary data to a text format like Base64 and decode it. I come up to the following one-liner by its terrible slow.

[System.Convert]::ToBase64String((Get-Content -AsByteStream file.tar)) | plink.exe -C -agent "remote_host" "base64 -di | tar xvf -"

I think I'll upload files and extract those separately.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.