Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Amending /etc/magic 1

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
I have a set of files which start with
Code:
#PK_BOOT
The file command recognises these as PK Zip files as there are entries in /etc/magic which look like
Code:
0      string          PK              PKZIP (.zip) compressed archive
1      string          PK              PKZIP (.zip) compressed archive
I've tried adding the line
Code:
1     string   PK_BOOT  Configuration File
both before and after the PKZIP entires. I've also tried
Code:
>4   string    BOOT     Configuration File
but I still get the file type as PKZIP. I added a dummy entry
Code:
0      string     columb    Test entry
which does work so the file is read in real time.

I'm now stuck. I need the file command not to see my configuration files as PKZIP files but still recognise PKZIP files correctly.

I would really appreciate some pointers on this as I' don't know what to try next.

Thanks

Columb Healy
 
PKZIP seems to be hardcoded in to file command - I tried magic file with both PKZIP entries commented out, but file still recognizes your "PK-BOOT" file as a zip file.

HTH,

p5wizard
 
To add to the confusion I amended /etc/magic so that the relevant section looks like
Code:
1       string          PK_BOOT         Thaler ubbconfig file
0       string          PK              PKZIP (.zip) compressed archive
1       string          PK              PKZIP (.zip) compressed archive
The results of my tests are
Code:
$ cat test.txt
#PK_BOOT
This is some text
$ file test.txt
test.txt:       PKZIP (.zip) compressed archive
$ file -m /etc/magic test.txt
test.txt:       Thaler ubbconfig file
Confused - I am!

Columb Healy
 
confused
thats an under statement
call me thick but
what exactly are you trying to achieve ?

How have you created this file ?
what should the actuall results be like?


 
The documentation is wrong about file and /etc/magic, at least on AIX. What file uses by default is a message catalog named magic.cat, which you'll find at /usr/lib/nls/msg/$YOUR_LANGUAGE/magic.cat.

Read the documentation for dispcat and gencat to learn how to modify the catalog. Be sure to document the change and save your source message file somewhere safe, because you'll have to reintegrate the change any time magic.cat is reinstalled/upgraded by AIX patches and such.


Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Rod Thanks for the explanation. For mere mortals like myself its going to be easier to force file to use /etc/magic using the -m flag.

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top