Benches Uncategorized

4

Pb converting plist to binary format

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi,

I have an XML plist generated by a perl program that I would like to convert to binary plist in a shell script. So I'm using the dedicated "plutil" program from the command line.

Alas it won't convert the plist to binary, leaving it in XML format wether I try :

plutil - convert binary1 fuel.plist

or

plutil -convert binary1 -o fuel2.plist fuel.plist

So I try this :

plutil -convert binary1 -o - fuel.plist

to send the result to the STDOUT.

Bingo, the output is definitely a binary plist as it starts with the "bplist" signature and is followed by lots of non human-readable characters.

But ... when I tried this :

plutil -convert binary1 -o - fuel.plist > fuel2.plist

Istill get that XML file !!

I tried with different filenames like fuel.db for the output in case plutil would reserve the .plist extension to XML format. I also validated the input file with plutil.

This is driving me crazy ... There must be something, but what ?

Any help appreciated 😉

Regards

Phil

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    etresoft

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    It sounds like you do not have permissions to modify this file nor to create new files in the directory. All you need is "plutil -convert binary1 "

  2. 0

    iPhil_good

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Actually I do ! I'm working in my Desktop directory !

    But ... OMG ... I've just found !!

    In fact both QuickLook and my text editor (here TextWrangler) convert binary plist files internally to their XML counterpart before showing them !!

    Now I've tried with Smultron which actually revealed a binary plist file !

    I should have checked the size of the file before plutil and after and noticed it had decreased from 41k to 8k !

    Regards

    Phil

  3. 0

    etresoft

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    "cat" is very handy for that sort of thing.

  4. 0

    thepagod

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Rather than 'cat' I would definitely suggest 'hexdump' as 'cat'ing a binay file to a terminal might lead to somewhat weird results. Try one of these:

    %> hexdump -C fuel2.plist

    %> hexdump -C fuel2.plist | less

    %> hexdump -C fuel2.plist | head

    Another possibility would be to test the type of the file using the 'file' utility:

    %> file fuel.plist

    fuel.plist: XML document text

    %> file fuel2.plist

    fuel2.plist: Apple binary property list

    I think that's rather clear 🙂

    HTH