我试图在Mac计算机上找到当前用户是否启用了iCloud Documents。我找到了它所在的plist(MobileMeAccounts.plist),但是我可以使用plistbuddy语法的一些帮助来在树中定位。
这是我到目前为止的脚本的一部分:
#!/bin/bash
# Purpose: Grab iCloud Document Status
plistBud="/usr/libexec/PlistBuddy"
if [[ -e "/Users/*loggedInUser*/Library/Preferences/MobileMeAccounts.plist" ]]; then
iCloudStatus=`$plistBud -c "print :Accounts:Services:MOBILE_DOCUMENTS" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist`
else
iCloudDocuments="Not Enabled"
fi
echo "$iCloudStatus"
我特意寻找以下代码:
<key>Enabled</key>
<true/>
这是plist。如果向下滚动,您将看到启用它的“MOBILE_DOCUMENTS”:
<?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>Accounts</key>
<array>
<dict>
<key>AccountAlternateDSID</key>
<string>99999999</string>
<key>AccountDSID</key>
<string>999999</string>
<key>AccountDescription</key>
<string>iCloud</string>
<key>AccountID</key>
<string>*****@gmail.com</string>
<key>AccountUUID</key>
<string>9999999</string>
<key>DisplayName</key>
<string>User Name</string>
<key>LoggedIn</key>
<true/>
<key>Services</key>
<array>
<dict>
<key>Name</key>
<string>CLOUDDESKTOP</string>
<key>ServiceID</key>
<string>com.apple.Dataclass.CloudDesktop</string>
<key>status</key>
<string>active</string>
</dict>
<dict>
<key>Name</key>
<string>FAMILY</string>
<key>ServiceID</key>
<string>com.apple.Dataclass.Family</string>
<key>showManageFamily</key>
<true/>
</dict>
<dict>
<key>Enabled</key>
<true/>
<key>Name</key>
<string>MOBILE_DOCUMENTS</string>
<key>ServiceID</key>
<string>com.apple.Dataclass.Ubiquity</string>
<key>apsEnv</key>
<string>production</string>
<key>authMechanism</key>
<string>token</string>
<key>url</key>
<string>https://p48-ubiquity.icloud.com:443</string>
<key>wsUrl</key>
<string>https://p48-ubiquityws.icloud.com:443</string>
</dict>