通过翻译提出的问题:
在centos中需要知道路由器的Wan IP,通过CMD保存到文件中。
行首是:
wget http://user:pass@192.168.1.1/RST_conn_status.htm | sed 's/\(.*\)\.\(.*\)\.\(.*\)\.\(.*\)'
有必要在文件 ex 中添加该行。测试.txt? 页面看起来像这样:
<TABLE border=1 cellpadding=2 cellspacing=0 width=100%>
<script>
var info_get_wanip="213.121.21.121";
var info_get_wanmask="255.255.255.255";
var info_get_gateway="0.0.0.0";
var info_get_dns1="83.111.121.10";
var info_get_dns2="83.111.121.14";
var ppp_uptime="338946";
var bpa_uptime="0";
var monthly_limit_reached="0";
我需要把info_get_wanip的数据写入test.txt
最佳答案
wget -O- http://user:pass@192.168.1.1/RST_conn_status.htm \
| perl -ne '/var info_get_wanip="((\d+\.){3}(\d+))"/ and print $1' \
> test.txt
关于linux - 使用路由器学习 wanIP (wget),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33999928/