- 论坛徽章:
- 2
|
本帖最后由 see_3000 于 2013-04-20 10:32 编辑
这个我已经实现了,代码如下, 很遗憾用的还是命令:
1. linux 版本:- #include <stdio.h>
- int main(void)
- {
- FILE *fp;
- char buffer[80];
- fp=popen("cat /etc/network/interfaces |grep ^iface\\ br-lan | awk -F ' ' '{print $4}'","r");
- fgets(buffer, sizeof(buffer), fp);
- printf("%s", buffer);
- pclose(fp);
- }
复制代码 2. openwrt版本:- #include <stdio.h>
- int main(void)
- {
- FILE *fp;
- char buffer[80];
- fp=popen("uci get network.lan.proto","r");
- fgets(buffer, sizeof(buffer), fp);
- printf("%s", buffer);
- pclose(fp);
- }
复制代码 |
|