Zip-ing on the fly

  • Follow


I want a filter that reads file names on stdin and writes the zipped files
to stdout on the fly:

Pseudocode:
write zip header on stdout
while not EOF(stdin) {
   read a single line from stdin containing the file name;
   write zipped version of file to stdout
}
write zip trailer to stdout


Zip 2.3 in www.info-zip.org  appears to allow reading file names
from stdin, or writing to stdout, but not both:
cat filelist|zip -r - -@>file.out
zip error: Invalid command arguments (can't use - and -@ together)

Is there another zip implementation that does what I want??

gtoomey




0
Reply nospam258 (216) 8/3/2003 10:57:57 AM

In comp.os.linux.misc Gregory Toomey <NOSPAM@bigpond.com> wrote:
> Zip 2.3 in www.info-zip.org  appears to allow reading file names
> from stdin, or writing to stdout, but not both:
> cat filelist|zip -r - -@>file.out

That's because  ...

> zip error: Invalid command arguments (can't use - and -@ together)


You want 

      cat filelist | xargs zip -r - > file.out


Peter
0
Reply ptb (2756) 8/3/2003 11:20:11 AM


Gregory Toomey <NOSPAM@bigpond.com> wrote:
> I want a filter that reads file names on stdin and writes the zipped files
> to stdout on the fly:

> Pseudocode:
> write zip header on stdout
> while not EOF(stdin) {
>   read a single line from stdin containing the file name;
>   write zipped version of file to stdout
> }
> write zip trailer to stdout

Mmmh, something like this?

$ for i in *;do zip $i.zip $i;done

-- 
Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for 
inconvenience, but I get tons of SPAM
0
Reply USENET22 (5462) 8/3/2003 11:22:08 AM

Gregory Toomey wrote:

> I want a filter that reads file names on stdin and writes the zipped files
> to stdout on the fly:
> 
> Pseudocode:
> write zip header on stdout
> while not EOF(stdin) {
>    read a single line from stdin containing the file name;
>    write zipped version of file to stdout
> }
> write zip trailer to stdout
> 
> 
> Zip 2.3 in www.info-zip.org  appears to allow reading file names
> from stdin, or writing to stdout, but not both:
> cat filelist|zip -r - -@>file.out
> zip error: Invalid command arguments (can't use - and -@ together)
> 
> Is there another zip implementation that does what I want??

zip - `cat filelist`

0
Reply me4 (18697) 8/3/2003 11:37:23 AM

"Michael Heiming" <michael+USENET@www.heiming.de> wrote in message
news:09rigb.0hd.ln@news.heiming.de...
> Gregory Toomey <NOSPAM@bigpond.com> wrote:
> > I want a filter that reads file names on stdin and writes the zipped
files
> > to stdout on the fly:
>
> > Pseudocode:
> > write zip header on stdout
> > while not EOF(stdin) {
> >   read a single line from stdin containing the file name;
> >   write zipped version of file to stdout
> > }
> > write zip trailer to stdout
>
> Mmmh, something like this?
>
> $ for i in *;do zip $i.zip $i;done

This produces lots of zip archvies; I want only one.

gtoomey


0
Reply nospam258 (216) 8/3/2003 11:41:56 AM

In comp.os.linux.misc Gregory Toomey <NOSPAM@bigpond.com> wrote:

> "Peter T. Breuer" <ptb@oboe.it.uc3m.es> wrote in message
> news:nuqigb.f19.ln@news.it.uc3m.es...
>> In comp.os.linux.misc Gregory Toomey <NOSPAM@bigpond.com> wrote:
>> > cat filelist|zip -r - -@>file.out
>>
>> > zip error: Invalid command arguments (can't use - and -@ together)
>>
>> You want
>>
>>       cat filelist | xargs zip -r - > file.out

> I simplified things too much. There is a Perl program that generates the
> file names, about one every 10 seconds.

> perlprog.sh|zip -r - -@>file.out

> xargs only runs commands when there is EOF on stdin (this is a

You are expressiing the difference between strict and lazy evaluation.
xargs must be strict because it cannot pass a partial command line to 
the process it executes.

> simplification). I want a partial zip file written after each file name is
> generated.

Where does the list of names that zip puts in the archive go?  If it's
at the end, you're OK.  If at the beginning, you're dead.

zip isn't meant to be a streaming archiver. use cpio or apio or tar.

Peter
0
Reply ptb (2756) 8/3/2003 12:20:11 PM

Gregory Toomey <NOSPAM@bigpond.com> wrote:
> "Michael Heiming" <michael+USENET@www.heiming.de> wrote in message
....
>> Mmmh, something like this?
>>
>> $ for i in *;do zip $i.zip $i;done

> This produces lots of zip archvies; I want only one.

From your pseudo code, I assumed you wanted multiple 
files.

$ ls | zip all.zip -@

-- 
Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for 
inconvenience, but I get tons of SPAM
0
Reply USENET22 (5462) 8/3/2003 12:50:01 PM

After confusing everyone (including me), I discovered a perl module
Archive::Zip
www.search.cpan.org/author/NEDKONZ/Archive-Zip-1.06/lib/Archive/Zip/FAQ.pod

and in it there is a "MockFileHandle" example
"examples/mfh.pl -- demo for use of MockFileHandle"

which can be adapted to do what I want.

gtoomey


0
Reply nospam258 (216) 8/4/2003 12:58:49 PM

Url should be http://tinyurl.com/iyhn
GT


0
Reply nospam258 (216) 8/4/2003 1:09:25 PM

8 Replies
195 Views

(page loaded in 0.267 seconds)

Similiar Articles:













7/28/2012 12:13:21 PM


Reply: