Decompress a .gz file

8 Antworten [Letzter Beitrag]
amenex
Offline
Beigetreten: 01/03/2015

This topic has its roots here: https://trisquel.info/en/forum/configure-hp-laserjet-p1505n-printer#comment-169989
where I downloaded HPLIP_Toolbox/hplip-3.22.10 which contains what appears to be a list of drivers:cups_drv.inc one of which is: ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gzwhich is probably a link to one or more compressed postscript drivers for my Hewlett-Packard LaserJet P1505n printer, which I had managed to bring to life by working with the CUPS page at localhost:631/admin.
However the print a self-test page command elicits the response that "If you can read this you are using the wrong printer driver."
The following script removes the directory-tree encumbrance:
cat cups_drv.inc | grep "ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz" | sed 's/\\//g' | tr '/' '\t' |awk '{print $3}' > hp-laserjet_p1505n-zxs.ppd.gzand places the compressed driver(s) list in the same directory as cups_drv.inc. That file is hp-laserjet_p1505n-zxs.ppd.gz which elicits a "not in gzip format" even when I try to extract it in Mate's file manager.
What next ?

AnhangGröße
hp-laserjet_p1505n-zxs.ppd_.gz30 Bytes
Cups-driver-list.txt37.7 KB
Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Your command line makes little sense. Unless the grepped driver name, "ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz", is not in the list (in which case nothing is output), it is the same as:
$ echo hp-laserjet_p1505n-zxs.ppd.gz > hp-laserjet_p1505n-zxs.ppd.gz

To actually list all the drivers names (the characters after "ppd/hpcups/" and before a space), here is a reasonable command line:
$ grep -o 'ppd/hpcups/[^ ]*' cups_drv.inc | cut -c 12-

You write uncompressed plain text in a file named "hp-laserjet_p1505n-zxs.ppd.gz". Despite the bad choice of extension, it is uncompressed plain text. To compress with GZip the output (on the standard output) of a command line, end it with '| gzip > out.gz' ("out.gz" can be any file name). But you had better use zstd, which is faster and provides greater compression ratios. For instance, with the above command line:
$ grep -o 'ppd/hpcups/[^ ]*' cups_drv.inc | cut -c 12- | zstd > out.zst

amenex
Offline
Beigetreten: 01/03/2015

Despite all my best efforts to be clear, let me emphasize: the listings in cups_drv.inc end in .gz .
They're compressed. The Internet steadfastly lists all such ppd files in compressed format. I want
to decompress them; and all my stabbings in the dark produce the answer that the .gz "files" are
not in gzip format.

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Unlike the file you attached to your original post (it contains the uncompressed plain text "hp-laserjet_p1505n-zxs.ppd.gz", as I explained), the files in the ppd/hpcups/ directory of https://sourceforge.net/projects/hplip/files/hplip/3.22.10/hplip-3.22.10.tar.gz are all "gzip compressed". In other terms, the following command line outputs no exception:
$ file ppd/hpcups/* | grep -v 'gzip compressed'

You can decompress them all with:
$ gunzip ppd/hpcups/*

Or, in your file manager listing the content ppd/hpcups/, you can "Select All" (Ctrl+A) and "Extract Here" (Enter).

I have no idea why you want to waste disk space by decompressing. If you want to interactively read such a gzip compressed file in the terminal, use less:
$ less ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz

If you want to process it with a command line, start it with zcat:
$ zcat ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz | ...

amenex
Offline
Beigetreten: 01/03/2015

I apologize for doubting ... I had not gotten around to checking the rest of the folders
in hplip-3.22.10, although I did say that the data in cups_drv.inc were probably links.
Then it turns out that hp-laserjet_p1505n-zxs.ppd.gz is just a plain-text file and not
compressed, in spite of its .gz extension.
It gets worse. Here is what CUhp-laserjet_p1505n-zxs.ppd.gzPS displays:
HP_LaserJet_P1505n (Idle, Accepting Jobs, Shared)
Description: HP LaserJet P1505n
Location: Upstairs Office T430-MB
Driver: HP LaserJet p1505n zxs, hpcups 3.22.10, requires proprietary plugin (color, 2-sided printing)
And worse yet: hp-laserjet_p1505n-zxs.ppd.gz is listed among the suggested drivers in the older list
of drivers in the current CUPS.
Worst of all: The driver requires proprietary plugin (color, 2-sided printing).
cd /media/george/Data-K2/george/Scripts/HPLIP_Toolbox/hplip-3.22.10/ppd/hpcups
less hp-laserjet_p1505n-zxs.ppd.gz ==> hp-laserjet_p1505n-zxs.ppd.gz: No such file or directory
zcat hp-laserjet_p1505n-zxs.ppd.gz ==> gzip: hp-laserjet_p1505n-zxs.ppd.gz: No such file or directory

[incomplete]

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Then it turns out that hp-laserjet_p1505n-zxs.ppd.gz is just a plain-text file and not compressed, in spite of its .gz extension.

After downloading, it is gzip compressed, like all the files in ppd/hpcups/. I have already shown it. One more time, for that specific file:
$ file ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz
ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.gz: gzip compressed data, was "hp-laserjet_p1505n-zxs.ppd", last modified: Thu Oct 27 13:17:08 2022, from Unix, original size modulo 2^32 14573

hp-laserjet_p1505n-zxs.ppd.gz: No such file or directory

You probably used gunzip before and you now have hp-laserjet_p1505n-zxs.ppd (which is uncompressed) instead of hp-laserjet_p1505n-zxs.ppd.gz (which was compressed). By default, gunzip deletes input files during decompression. Option --keep (-k) can be used to keep them.

amenex
Offline
Beigetreten: 01/03/2015

Taking everyone's word for it that hp-laserjet_p1505n-zxs.ppd is a plain text file, I opened
it with FeatherPad (no complaints) and saved it here as hp-laserjet_p1505n-zxs.ppd.txt. The
installation cannot print. A previous ppd file works OK but the printer self test output is
that banner which says I'm using the wrong printer driver.
zcat hp-laserjet_p1505.ppd.gzdoes indeed decompress and outputs what may be at
first glance hp-laserjet_p1505n-zxs.ppd.txt. At any rate, I may have accidentally hit on
the correct decompression syntax yesterday.
Available printer drivers ==> lpinfo -m | grep 1505n
foo2zjs:0/ppd/foo2zjs/HP-LaserJet_P1505n.ppd HP LaserJet P1505n Foomatic/foo2xqx (recommended)
hplip:0/ppd/hplip/HP/hp-laserjet_p1505n-zxs.ppd HP LaserJet p1505n zxs, hpcups 3.21.12 (fails)
There is apparently no better driver available. My best guess is that the existing foo2xqx one
has an undetected flaw that produces the warning banner with the self test but works OK otherwise.
Sorry to have put you to all this trouble ... unless there is a way of finding and decompressing
the recommended driver.

AnhangGröße
hp-laserjet_p1505n-zxs.ppd_.txt 14.23 KB
Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010

Taking everyone's word for it that hp-laserjet_p1505n-zxs.ppd is a plain text file, I opened it with FeatherPad (no complaints) and saved it here as hp-laserjet_p1505n-zxs.ppd.txt.

Do you understand that the file name (including a possible extension) does not affect the content of the file, hence its type? The command line in your original post was writing uncompressed plain text to a file named "hp-laserjet_p1505n-zxs.ppd.gz". As a consequence, that file is uncompressed plain text, no matter the fact its name ends with ".gz". This time, hp-laserjet_p1505n-zxs.ppd is a PPD file (a plain text format) as https://en.wikipedia.org/wiki/PostScript_Printer_Description presents it:
$ file ppd/hpcups/hp-laserjet_p1505n-zxs.ppd
ppd/hpcups/hp-laserjet_p1505n-zxs.ppd: PPD file, version "4.3"

Appending ".txt" to its name does not change its type:
mv ppd/hpcups/hp-laserjet_p1505n-zxs.ppd ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.txt
$ file ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.txt
ppd/hpcups/hp-laserjet_p1505n-zxs.ppd.txt: PPD file, version "4.3"

Since HP distributes gziped compressed PPD files, that is probably what the system expects. By decompressing, renaming, ... (and not understanding what you are doing), you just create problems and confusion.

prospero
Offline
Beigetreten: 05/20/2022

"Do you understand that the file name (including a possible extension) does not affect the content of the file, hence its type?"

Clearly, yes:

"it turns out that hp-laserjet_p1505n-zxs.ppd.gz is just a plain-text file and not compressed, in spite of its .gz extension."