在Mac上使用scutil,我知道如何创建一个dict并将其放在数据存储中。
但是,我的系统显示一个键,其值只是一个数组:
$ scutil
> show Kerberos-Default-Realms
<array> {
0 : ATHENA.MIT.EDU
}
如何手动创建这样的条目?我需要在自动测试中执行此操作。
答案 0 :(得分:1)
我可能已找到答案(修订):
$ scutil
> help
Available commands:
help : list available commands
f.read file : process commands from file
quit : quit
d.init : initialize (empty) dictionary
d.show : show dictionary contents
d.add key [*#?] val [v2 ...] : add information to dictionary
(*=array, #=number, ?=boolean)
d.remove key : remove key from dictionary
list [pattern] : list keys in data store
add key ["temporary"] : add key in data store w/current dict
get key : get dict from data store w/key
set key : set key in data store w/current dict
show key ["pattern"] : show values in data store w/key
remove key : remove key from data store
notify key : notify key in data store
n.list ["pattern"] : list notification keys
n.add key ["pattern"] : add notification key
n.remove key ["pattern"] : remove notification key
n.changes : list changed keys
n.watch : watch for changes
n.cancel : cancel notification requests
要重新创建上述问题中的示例:
> d.init
> d.add Kerberos-Default-Realms * ATHENA.MIT.EDU
> d.show
<dictionary> {
Kerberos-Default-Realms : <array> {
0 : ATHENA.MIT.EDU
}
}
...和废话,这不完全符合你的需要,现在呢?我的意思是,确保你有一个具有正确值的数组,但该数组在字典中。
你正在寻找更多的东西:
> d.show
<array> {
0 : ATHENA.MIT.EDU
}
这意味着我们需要更像的东西:
> a.init
a.init: unknown, type "help" for command info
数字......等等!如果我:
怎么办?> get Kerberos-Default-Realms
> d.show
<array> {
0 : ATHENA.MIT.EDU
}
甜蜜,现在我的“当前字典”是一个数组,所以我应该可以从这里开始工作:
> d.add Kerberos-Default-Realms ATHENA.MIT.EDU ZEUS.MIT.EDU
d.add: data (fetched from configuration server) is not a dictionary.
不......这是我最后的希望......我知道NSArray是一个有效的NSObject,我不认为scutil是为了支持添加或修改NSMutableArray而构建的。
显然有一些方法可以让它进入动态存储(因为Kerberos-Default-Realms是一个数组),但是对我来说scutil看起来像死路一条......只剩下一件事了:
> quit