Help with an Extension Attribute script

Not applicable

Any Teamviewer users out there?

I would like to grab the ClientID from the Teamview plist

Its the 2nd key in the dictionary.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict> <key>ClientIC</key> <integer>1869728100</integer> <key>ClientID</key> <integer>262023163</integer>

The path to the file is:
~/Library/Preferences/com.TeamViewer.Settings.plist

sed and awk are not my closest friends.

--
Doug Hanley doug at mac-tek.com - 702-396-0697 Apple Certified Systems Administrator - Apple Certified Trainer Apple Certified Support Professional - Apple Certified Technical Coordinator
MacTEK Consulting & Training - http://www.Mac-TEK.com Apple Authorized Training Center (IT & Pro Apps) - Adobe Authorized Training Center
Apple Consultants Network Member - Apple Authorized Service Provider

7 REPLIES 7

justinrummel
Contributor III

PlistBuddy -c "Print :ClientID"
~/Library/Preferences/com.TeamViewer.Settings.plist

- Justin Rummel

jcrowe
New Contributor

Should be something like:

defaults read ~/Library/Preferences/com.TeamViewer.Settings ClientID

Justin

Not applicable

Yeah that's the issue. Defaults Read won't get it from the current logged in user.
On Jun 16, 2011, at 5:43 PM, David Moyle wrote:
I think its back to greping the plist from the path ~/Library/Preferences...
--
Doug Hanley doug at mac-tek.com - 702-396-0697 Apple Certified Systems Administrator - Apple Certified Trainer Apple Certified Support Professional - Apple Certified Technical Coordinator
MacTEK Consulting & Training - http://www.Mac-TEK.com Apple Authorized Training Center (IT & Pro Apps) - Adobe Authorized Training Center
Apple Consultants Network Member - Apple Authorized Service Provider

tlarkin
Honored Contributor

Casper scripts run as root so you either need to use some sort of
current user detection or loop through all users to store the info.

sean
Valued Contributor

A bunch of recent posts have explained how to grab the current user:

ls -l /dev/console | awk '{print $3}'

Beware, if you run the defaults command as root, then you will change the ownership and group of that file to root instead. If you wish to run a command as a user then you can use something like:

su [username] -c 'defaults write ~/Library/Preferences/com.apple.iTunes invertStoreLinks -bool yes'

will edit the com.apple.iTunes.plist file for [username], maintaining ownership to [username].

Sean

rmanly
Contributor III

!/bin/bash

for username in /Users/; do if [[ -a "${username}/Library/Preferences/com.TeamViewer.Settings.plist"
]]; then clientid=$(PlistBuddy -c "Print :ClientID"
~/Library/Preferences/com.TeamViewer.Settings.plist) echo "<result>${username##
/} has the ClientID ${clientid}</result>" else echo "<result>${username##*/} has no ClientID</result>" fi
done

Came up with that quick and dirty...should work, have not tested with
another plist. If you dont want /Users/Shared muddying up the outcome
you can iterate over the UID > 500 per Larkin's now famous one-liner.
It can be found all over the place ;) That would change the path for
the test and also wouldn't need the bash string manipulation to get
just the name by itself though.

Good luck,

Ryan M. Manly
Glenbrook High Schools

rmanly
Contributor III

ack! This

clientid=$(PlistBuddy -c "Print :ClientID"
~/Library/Preferences/com.TeamViewer.Settings.plist)

needs to be

clientid=$(PlistBuddy -c "Print :ClientID"
"${username}/Library/Preferences/com.TeamViewer.Settings.plist")

Ryan M. Manly
Glenbrook High Schools