Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using defaults read to get value from plist Post 302250297 by davewg on Thursday 23rd of October 2008 05:35:57 AM
Old 10-23-2008
Question Using defaults read to get value from plist

Hi there,

I'm trying to retrieve a value from a plist file, which I have done before with no problems, however this plist file looks a little different....

Normally it's like this;
<plist version="1.0">
<dict>
key>KeyName</key>
<string>blah</string>

I want the value of KeyName, so 'defaults read com.example KeyName' returns the value "blah".

But the plist I'm having problems with is like this....
<plist version="1.0">
<dict>
key>HEADING</key>
<dict>
<key>KeyName</key>
<string>blah</string>

...and 'defaults read com.example KeyName' returns an error saying the domain/default pair does not exist.

Please can anyone advise if there is a way to retrieve this value?

Kind Regards
davewg
 

10 More Discussions You Might Find Interesting

1. IP Networking

defaults httpd.conf

I have found in the httpd.conf where it it states the default parse pages like index.htm, index.html, index.php and etc....However, my computer box does not seem to want to automatically load the index.php files. Anyone have any ideas? (5 Replies)
Discussion started by: macdonto
5 Replies

2. Shell Programming and Scripting

Using 'defaults read' and storing the output in a variable

Hi all, I'm creating a script which uses 'defaults read' to retrieve details from an Info.plist like this; defaults read "/Path/Contents/Info" CFBundleShortVersionString This works fine in Terminal and returns the expected values. Is it possible to use this command in a script, and... (0 Replies)
Discussion started by: davewg
0 Replies

3. OS X (Apple)

the best way of editing .plist files

:( what is the best way of editing the various .plist files without adding third party files? Or is the easiest way is to add third party applications, which ones? please kept in mind that i am not a programmer. mike (1 Reply)
Discussion started by: mehow
1 Replies

4. UNIX for Dummies Questions & Answers

max os x .plist not running as scheduled?

Hello all, I am admittedly a newbie and have created a plist designed to fire off a shell script everyday at 3:00pm. It is located in /Library/LaunchDaemons/. I use it to mirror a hard local drive with a remote one. It worked one time but not again after that. I never restart the machine... (0 Replies)
Discussion started by: Movomito
0 Replies

5. UNIX for Advanced & Expert Users

assigning variables to their defaults

Hi, Is there any way to assign defaults values to the shell variables without reassigning them ( restarting the session) for example after login the value of ORACLE_HOME=/a/b/c i have changed this value from the console export ORACLE_HOME=/c/d now what if i want the value exported to... (1 Reply)
Discussion started by: clx
1 Replies

6. OS X (Apple)

Plist to Unix Executable

I'm using an old conversion method for converting a plist into an XML file, but that's not what I'm needing just via terminal now. What I'm looking for is an answer to convert a plist file into an executable. I'd like to import it into Casper and have the JSS push it out onto an image. In this... (6 Replies)
Discussion started by: unimachead
6 Replies

7. Shell Programming and Scripting

Parsing plist file ?

Hi, I wondered if it was possible to parse a plist file like this http://dl.dropbox.com/u/14586156/stuff/Bookmarks.plist so it will afterwards look like this <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"... (0 Replies)
Discussion started by: pasc
0 Replies

8. Shell Programming and Scripting

Parse hdiutil -plist data for specific info

I am trying to get the mounted size of a compressed .dmg. I can use hdiutil imageinfo -plist $imagename to get a lot of info, including what I need. The problem is that I have no idea how to parse that single piece of info into a variable (or in this case, array element). Here is what I have so... (2 Replies)
Discussion started by: nextyoyoma
2 Replies

9. Shell Programming and Scripting

Defaults read/write question

OSX 10.9 How does "defaults" know where to look for .plists? To expand: defaults read com.apple.finder is located in ~/Library/Preferences but, defaults read com.apple.mail is located in ~/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist So my question... (0 Replies)
Discussion started by: sudo
0 Replies

10. Shell Programming and Scripting

Editing .plists with defaults

I've done simple edits with defaults, but they usually are the parent parameter. For example changing the value of "DateCellWidthCache" =. What if I want to change a parameter in one of the sub categories such as "MMM d, y' '",? How do I type that out at the end of my defaults write command?: ... (1 Reply)
Discussion started by: sudo
1 Replies
PLISTBUDDY(8)						    BSD System Manager's Manual 					     PLISTBUDDY(8)

NAME
PlistBuddy -- read and write values to plists SYNOPSIS
PlistBuddy [-cxh] file.plist DESCRIPTION
The PlistBuddy command is used to read and modify values inside of a plist. Unless specified by the -c switch, PlistBuddy runs in interactive mode. The following commands are used to manipulate plist data: Help Prints this information. Exit Exits the program. Changes are not saved to the file. Save Saves the current changes to the file. Revert Reloads the last saved version of the file. Clear type Clears out all existing entries, and creates root of type type. See below for a list of types. Print [entry] Prints value of entry. If an entry is not specified, prints entire file. See below for an explanation of how entry works. Set entry value Sets the value at entry to value. Add entry type [value] Adds entry with type type and optional value value. See below for a list of types. Copy entrySrc entryDst Copies the entrySrc property to entryDst. Delete entry Deletes entry from the plist. Merge file [entry] Adds the contents of plist file to entry. Import entry file Creates or sets entry to the contents of file. Entries consist of property key names delimited by colons. Array items are specified by a zero-based integer index. Examples: :CFBundleShortVersionString :CFBundleDocumentTypes:2:CFBundleTypeExtensions Entries may be of the following types: string array dict bool real integer date data OPTIONS
-c command Execute command and exit. By default, PlistBuddy will run in interactive mode. -x Output will be in the form of an xml plist where appropriate. -h Print the complete help info. EXAMPLES
Set the CFBundleIdentifier property to com.apple.plistbuddy: Set :CFBundleIdentifier com.apple.plistbuddy Add the CFBundleGetInfoString property to the plist: Add :CFBundleGetInfoString string "App version 1.0.1" Add a new item of type dict to the CFBundleDocumentTypes array: Add :CFBundleDocumentTypes: dict Add the new item to the beginning of the array: Add :CFBundleDocumentTypes:0 dict Delete the FIRST item in the array: Delete :CFBundleDocumentTypes:0 dict Delete the ENTIRE CFBundleDocumentTypes array: Delete :CFBundleDocumentTypes EXIT STATUS
PlistBuddy command returns a zero exit status if it succeeds. Non zero is returned in case of failure. Mac OS X February 19, 2007 Mac OS X
All times are GMT -4. The time now is 05:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy