Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: dynamic zcat and grep

by swampyankee (Parson)
on Mar 21, 2006 at 21:50 UTC ( #538321=note: print w/ replies, xml ) Need Help??


in reply to dynamic zcat and grep

I believe this line:

open INFILE, 'zcat $filename |' or print "ERROR - Could not open $fil +ename";
is running afoul of Perl's quoting convention; single quotes don't interpolate variable values. Try replacing the single quotes with double quotes.

emc

" The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
—Nathaniel S. Borenstein


Comment on Re: dynamic zcat and grep
Download Code
Re^2: dynamic zcat and grep
by clmcshque (Initiate) on Mar 21, 2006 at 22:38 UTC
    Thanks for the reply. I've tried many different encarnations of that line:
    open(INFILE, "zcat $filename |") open(INFILE, 'zcat $filename |') open INFILE, "zcat $filename |"
    all with the similar results.
    zcat: compressed data not read from a terminal. Use -f to force decomp +ression. For help, type: zcat -h

      Sorry my help was not helpful.

      I've looked at the docs for zcat (well, OpenBSD's docs for zcat) and it seems that your first and third choices should work: zcat unzips the input file to STDOUT. When I get a chance (probably about 24 hours from now), I'll muck about on by OpenBSD box to see if I can replicate your results.

      emc

      " The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
      —Nathaniel S. Borenstein
      Can you use your zcat in a pipe on the command line? Like

      % cat file.gz | zcat | less

      This works on Solaris but if it doesn't work for you it could be that your zcat demands the presence of a terminal as implied by your results.

      Cheers,

      JohnGG

        On the command line I use:
        $ zcat file.gz | grep ...
        Which works just fine. Is that the same?
Re^2: dynamic zcat and grep
by Anonymous Monk on Oct 03, 2012 at 02:13 UTC

    This is an old thread but this answer may prove useful to others, I had a similar problem with a command similar to

    zcat -c test.gz | pythonscript.py > test.out

    being called within a makefile, it had the same error as mentioned in this thread. I ended up changing it to

    cat test.gz | zcat -c | pythonscript.py > test.out

    Regards Brad

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://538321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-09-02 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (31 votes), past polls