powershell - Compressing to tar.xz using 7-zip through a pipe on windows -
my command line (powershell):
$7z ="`"c:\program files\7-zip\7z.exe`"" &$7z -r -ttar -bd -so . | &$7z -r -txz -bd $archive -si
the produced archive file indeed contains tar file, tar file corrupt.
note, breaking pipe 2 commands works correctly:
&$7z -r -ttar -bd ${archive}.tmp . &$7z -r -txz -bd $archive ${archive}.tmp
the produced archive valid.
so, wrong pipeline?
(i using powershell)
try adding | %{ "$_" }
in between pipes like
&$7z -r -ttar -bd -so . | %{ "$_" } | &$7z -r -txz -bd $archive -si
the point second call 7z
expects unmodified data on stdin, powershell converting output first call 7z
(multiple) (string) objects. %
alias foreach-object
, additional command loop on each object , convert plain string before passing on second call 7z
.
edit: reading through powershell’s object pipeline corrupts piped binary data looks me if suggestion not work, , there's no way fix it. well, other wrapping whole pipeline cmd /c "..."
call make cmd
, not powershell handle pipeline.
edit2: trying this solution powershell cookbook, slow.
in end, created .cmd
script 7z
pipes i'm calling powershell script.
Comments
Post a Comment