Write-Tar/Write-GZip Not working together?

Topics: User Forum
Jul 6, 2011 at 6:10 PM

I'm trying to use the Write-Tar and Write-GZip cmdlets to create a .tar.gz file. The example when you type "help write-tar" suggests the following should work:

  • dir c:\logs\ -rec -inc *.log | write-tar -output logs.tar | write-gzip -level 9

This creates a "logs.tar" file, but does not compress anything, or create a logs.tar.gz file.

If instead I break it up into two steps:

  • "dir c:\logs\ -rec inc *.log | write-tar -output logs.tar
  • get-item logs.tar | write-gzip -level 9

I get a compressed copy of logs.tar called "logs.tar.gz" as I would expect.

Am I missing something?

Developer
Jul 7, 2011 at 4:50 PM
you might need to add -passthru to write-tar

On Wednesday, July 6, 2011, JohnPrice <notifications@codeplex.com> wrote:
> From: JohnPrice
> I'm trying to use the Write-Tar and Write-GZip cmdlets to create a .tar.gz file. The example when you type "help write-tar" suggests the following should work:
>
> dir c:\logs\ -rec -inc *.log | write-tar -output logs.tar | write-gzip -level 9
>
> This creates a "logs.tar" file, but does not compress anything, or create a logs.tar.gz file.
> If instead I break it up into two steps:
>
> "dir c:\logs\ -rec inc *.log | write-tar -output logs.tar
> get-item logs.tar | write-gzip -level 9
> I get a compressed copy of logs.tar called "logs.tar.gz" as I would expect.
> Am I missing something?
> Read the full discussion online <http://pscx.codeplex.com/discussions/264141#post638284>. To add a post to this discussion, reply to this email ([email removed] <[email removed]?subject\x3d[Pscx:264141]>) To start a new discussion for this project, email [email removed] You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings <https://pscx.codeplex.com/subscriptions/thread/project/edit> on codePlex.com. Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

--

---
404 signature missing
Jul 7, 2011 at 6:00 PM

Write-Tar doesn't seem to support a -passthru switch?

I'm using the 2.0 package; I don't know if there have been changes to the source since then. I guess TFS is down on codeplex right now so I just get an error when I try to have a look.

Developer
Jul 7, 2011 at 6:45 PM
You know what John, this might be a problem with the 2.0 build - we had some esoteric issues with pipelining things that have been fixed in the latest source code. Do you know anyone who could build you something from the current source code tree?

On Thu, Jul 7, 2011 at 2:00 PM, johnprice <notifications@codeplex.com> wrote:

From: johnprice

Write-Tar doesn't seem to support a -passthru switch?

I'm using the 2.0 package; I don't know if there have been changes to the source since then. I guess TFS is down on codeplex right now so I just get an error when I try to have a look.

Read the full discussion online.

To add a post to this discussion, reply to this email (Pscx@discussions.codeplex.com)

To start a new discussion for this project, email Pscx@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--

---
404 signature missing
Jul 7, 2011 at 6:55 PM

If I can just get source via the "Source Control" tab on codeplex, I think I should be able to build things for myself. As I said, though, it looks like that portion of CodePlex is down for maintenance right now, so I'll have to check back later.

If there's more involved in getting access to the source and building, then I may require some assistance.

Developer
Aug 2, 2011 at 3:15 PM

Did you manage to get a working build?

Aug 2, 2011 at 4:54 PM

Sorry... just after I posted this I got pulled onto something else entirely and so hadn't followed up.

I tried just grabbing the source now, though, but don't have VS2010 on my work machine, so can't open the solution. I get an "unspecified error" trying to open any of the projects; not sure if that's because of the source control bindings or not having 2010.

Anyway, short answer is no, I'm not able to get a working build.

Aug 28, 2013 at 12:53 AM
I can confirm that this is still borged with the 2.1.1 ProductionDec 16, 2012, Stable release, it's actually broken to the point where -OutputPath is entirely ignored by the cmdlet, resulting in an archive per file situation.
May 6 at 8:27 AM
Hi!

I'm new to CodePlex, PowerShell and all that jazz, but I am eager to learn a little more PS. Although I got tar.exe from PoshGit, I wanted to be able to use Write-Tar and Write-GZip to be able to create an archive of a directory (at first), but I did not succeed. I keep getting all sorts of errors, along with the fact that the -PassThru option is not suspported. I'm using PSCX v3.0 and I can't seem to get a running pipe together. Could I get some directions how to do it and why?

Thanks in advance.
Jul 22 at 11:45 AM
Is the project still active? Is there any hope of getting an update to buggy write-gzip? (Plus getting new features such as ssh, but that's a different topic.)

If the project is dead, I'll look to alternative methods to extending my Powershell environment.
Coordinator
Jul 22 at 2:30 PM
No not dead. The project contributors have just been busy. :-) Can you post the specific errors you are seeing?
Jul 23 at 5:16 AM
This thread is roughly 3 years old. Roughly 2 months ago I posted that I believe the problem still persists, namely that there's no way to create a .tgz file in just one pipe. There are no errors. Things just don't work.
  • Files tar-ed together are not gzip-ped. Just as the original poster claimed, nothing happens. When broken into 2 steps, it works.
  • Write-GZip cannot compress multiple files into a single archive. Even though Get-Help suggests that when -OutputPath is specified, this is what will happen, it's not true.
  • Is there any apparent reason why the interfaces of Write-Zip, Write-GZip and Write-Tar differ? Not too much, but it does a little. -Append -FlattenPaths -IncludeEmptyDirectories are only supported by Write-Zip. (Not to mention that the example features the undocumented -RemoveOriginal switch) I am a complete PS idiot, and would appreciate if EntryPathRoot spared at least just a few words what it does.
All of this happens in PSCX 3.1 Under Win8.1.

I am just getting the hang of PS, but I really like what I saw so far. If only these things would work. Frustrations aside, the credit is yours guys.
Developer
Jul 23 at 2:28 PM
Edited Jul 23 at 2:29 PM
GZip isn't a "container" format like Zip or Tar, so it only works on single files. This is why you always pipe a Tar to Gzip because Tar files' contents are not compressed, just aggregated. If the help or interface suggests otherwise, this is not intended.

Tar piped to Gzip used to work fine -- I apologize if it got inadvertently broken. I will investigate.