1. shell 脚本:ubus 读取参数结合 json 函数–读取
一级数据
root@OpenWrt:/# ubus call system board
{
"kernel": "3.18.8",
"hostname": "OpenWrt",
"system": "Atheros AR9341 rev 1",
"model": "Atheros DB120 reference board",
"release": {
"distribution": "OpenWrt",
"version": "Bleeding Edge",
"revision": "r44627",
"codename": "chaos_calmer",
"target": "ar71xx\/generic",
"description": "OpenWrt Chaos Calmer r44627"
}
}
root@OpenWrt:/#
root@OpenWrt:/# cat /test.sh
#!/bin/sh
# Copyright (C) 2011 OpenWrt.org
. /usr/share/libubox/jshn.sh
json_load "$(ubus call system board)"
json_get_var model model
echo $model
root@OpenWrt:/# sh test.sh
model=Atheros DB120 reference board
root@OpenWrt:/#
� 1
� 2
� 3
� 4
� 5
� 6
评论0
最新资源