标题: 研究了好几天了刚刚找到这里,高手帮我解决一下。
[打印本页]
作者: cxinet
时间: 2007-1-31 19:13
标题: 研究了好几天了刚刚找到这里,高手帮我解决一下。
本人刚刚接触批处理碰到一个头疼的问题
我在写静态路由表时候使用错误网关会出现下面这句(The route addition failed: Either the interface index is wrong or the gateway do
es not lie on the same network as the interface. Check the IP Address Table for
the machine.)
因为这句话很专业,好多领导看不懂所以我想利用批处理简化一下这局话。在出现这句话时候把上面那句英文改为(检查网关);如不出现这句话则直接运行下一句。
这样的批处理可以实现吗?应该如何去写。
在这里先谢谢各位前辈了。
路由表语法是route -p add 192.168.1.2 mask 255.255.255.0 192.168.1.1 metric 1
机器IP是192.168.0.2 网关是192.168.0.1 子网掩码255.255.255.0
我要解决的问题不是如何设置网关、IP或者不让那具英文出现;而是将那句英文改为检查网关四个字。
Last edited by cxinet on 2007-1-31 at 06:47 AM ]
作者: Climbing
时间: 2007-1-31 22:08
首先,你的route -p add那一个命令行是错误的,这可能是导致出现错误的关键,如果彻底消除了错误,恐怕就没有必要检测错误了。
我认为正确的应该是:route -p add 192.168.0.0 mask 255.255.255.0 192.168.0.1 metric 1
至于检测错误,可以使用这种方式:
route -p add .... 2>&1 | find /i "addition failed"
if %errorlevel%==0 echo 请检查网关!
作者: jastyg
时间: 2007-2-1 00:31
route add 192.168.0.0 mask 255.255.255.0 192.168.0.1 metric 1 -p
我都是这样写
作者: cxinet
时间: 2007-2-1 05:20
2楼的大哥能不能写个完整的批处理,那个“至于检测错误,可以使用这种方式”我还是搞不懂。
还有Climbing你是保定的?我也是保定的。
作者: cxinet
时间: 2007-2-1 06:22
上面的静态路由表确实有问题,我的意思是出现(The route addition failed: Either the interface index is wrong or the gateway do
es not lie on the same network as the interface. Check the IP Address Table for
the machine.)这句话时候如何用中文只是,并不是路由表问题。
也就是说不再让The route addition failed: Either the interface index is wrong or the gateway do
es not lie on the same network as the interface. Check the IP Address Table for
the machine.这句话出现了,而是直接出现检查网关
Last edited by cxinet on 2007-1-31 at 05:23 PM ]
作者: oilio
时间: 2007-2-1 09:03
哎,好难啊,不仅涉及到命令还涉及到网络。只能干看看了。route是路由命令??
作者: Climbing
时间: 2007-2-1 22:25
route -p add .... 2>&1 | find /i "addition failed" >nul
if %errorlevel%==0 echo 请检查网关!