Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: dynamic zcat and grep

by clmcshque (Initiate)
on Mar 21, 2006 at 23:50 UTC ( [id://538351]=note: print w/replies, xml ) Need Help??


in reply to Re: dynamic zcat and grep
in thread dynamic zcat and grep

Thanks for the reply. I'm using - perl, v5.8.7 built for i686-linux Red Hat Enterprise zcat works for me when I enter it via the command line, not when it is in a perl script. gunzip -c gives the same errors. When I use single quotes:
gunzip: compressed data not read from a terminal. Use -f to force deco +mpression. For help, type: gunzip -h
When I use double quotes:
ERROR - Could not open log.gz

Replies are listed 'Best First'.
Re^3: dynamic zcat and grep
by jasonk (Parson) on Mar 22, 2006 at 00:39 UTC

    Since you are on a Red Hat machine anyway, you can save yourself a lot of time just by using 'zgrep'.


    We're not surrounded, we're in a target-rich environment!
      Thanks for the reply. zgrep works great on the command line, but how do I get it to work within my script? Could I do the following: (I would try it but don't have access to the system right now)
      $grep = /something/; $gzfile = file.gz; open OUTPUT "zgrep $grep $gzfile |";
Re^3: dynamic zcat and grep
by johngg (Canon) on Mar 22, 2006 at 10:50 UTC
    You may be able to get a better idea of what is going wrong if you include $! in your error message. This is the variable in which Perl stores the O/S error message when things like open fail, e.g.

    $fn = "non_existant_file"; open IN, "<$fn" or die "open: $fn: $!\n";

    would error with

    open: non_existant_file: no such file or directory

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found