Re: Reading nested key-value pairs in plist
Re: Reading nested key-value pairs in plist
- Subject: Re: Reading nested key-value pairs in plist
- From: Paul Skinner <email@hidden>
- Date: Wed, 18 Dec 2002 15:09:53 -0500
On Wednesday, December 18, 2002, at 10:25 AM, Reinhold Penner wrote:
I've been playing with "defaults read..." for some time now and I can't
get it to work with more complex structures such as
com.apple.internetconfig.plist (it's fairly straightforward in simple
plist files, but this one is too nested for me. What I want to read is
a particular key (in this case "DownloadFolder"). I looked at the man
page for defaults and found this "very helpful" bug:
BUGS
Defaults can be structured in very complex ways, making it
difficult for
the user to enter them with this command.
I can get as far as spewing out the entire dictionary using
do shell script "defaults read com.apple.internetconfig 'Version
2.5.3'"
but obviously that's not too helpful. I can also grep for
DownloadFolder like this
do shell script "defaults read com.apple.internetconfig 'Version 2.5.3'
| grep 'DownloadFolder'"
--> " DownloadFolder = {"
but unfortunately, the value for that key is in the next line.
So, has anyone managed to retrieve a specific key-value pair from
internetconfig or another complex plist file? Or does anyone know of a
clever method to get the path of the user's download folder? Any code
is fine (Objective C, Java, AS, shell, KlingonScript, ... anything). I
would also settle for a construct that would access the next line of
the grep example shown above (JD, you surely must know how to do that).
TIA for any pointers, -Reinhold
I don't know what you're going to be able to do with the result...
set d to do shell script "defaults read com.apple.internetconfig "
set AppleScript's text item delimiters to "DownloadFolder = "
set p to text item 2 of d
set AppleScript's text item delimiters to ";"
set p to text item 1 of p
-->{
"ic-data" = <05746974 616e0000 01ed0000 00006f61 64466f6c
64657200 00000000 00008007 b8aa18de ff9c0001 a2a80044 6f776e6c 6f616473
6567124d 50454720 4c617965 72203220 41756469 6f6d7366 74000000 32bfff00
02115175 69636b54 696d6520 506c7567 696e00da 80bf0000 00000136 00020001
05746974 616e0000 00000000 00000000 00000000 00000000 00000000 b8aa18de
482b0000 000161f5 09446f77 6e6c6f61 64730000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 0001a2a8 b770bea6 004801ca 030b04be ffffffff 00000120
00000000 00000000 00000000 00000008 7061756c 736b696e 00100008 0000b8aa
5f2e0000 00110008 0000b770 f6e60000 00010008 000161f5 00002291 0002001e
74697461 6e3a5573 6572733a 7061756c 736b696e 3a446f77 6e6c6f61 6473000e
00140009 0044006f 0077006e 006c006f 00610064 0073000f 000c0005 00740069
00740061 006e0012 00185573 6572732f 7061756c 736b696e 2f446f77 6e6c6f61
64730013 00012f00 ffff0000 >
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.