我试图从AccountID "/Library/Preferences/MobileMeAccounts.plist“中的MobileMeAccounts plist中读取键”macOS“的值,并得到错误:
/usr/libexec/PlistBuddy -c "print :Accounts:AccountID" /Users/username/Library/Preferences/MobileMeAccounts.plist错误:“打印:条目”:“帐户:AccountID”,不存在“
如果我向上移动一个节点,下面是输出的一个片段:
/usr/libexec/PlistBuddy -c "print :Accounts" /Users/username/Library/Preferences/MobileMeAccounts.plist输出:
<?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>b95dc8b6-8ec4-4644-ade8-ca8e3eeb1f82</string>
<key>AccountDSID</key>
<string>12345678901</string>
<key>AccountDescription</key>
<string>iCloud</string>
<key>AccountID</key>
<string>username@domain.com</string> * * * * * * * * * * * How do I access this value?
<key>DisplayName</key>
<string>firstName lastName</string>
<key>LoggedIn</key>
<true/>
<key>Services</key>
<array>在这个例子中,为了输出"username@domain.com“,我似乎不知道我遗漏了什么简单的东西。
发布于 2022-06-12 02:07:45
正如Gordon Davisson指出的那样:"Accounts包含一个数组,您需要指定您想要的数组的哪个元素。尝试打印:Accounts:0:AccountID。“
https://stackoverflow.com/questions/72586848
复制相似问题