<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>风叶 &#187; ping</title>
	<atom:link href="http://blog.myhnet.cn/tag/ping/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.myhnet.cn</link>
	<description>秋湍泻石髓 风叶聚云根</description>
	<lastBuildDate>Fri, 20 Aug 2010 15:05:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>一个检测PING结果的脚本</title>
		<link>http://blog.myhnet.cn/2007/12/26/%e4%b8%80%e4%b8%aa%e6%a3%80%e6%b5%8bping%e7%bb%93%e6%9e%9c%e7%9a%84%e8%84%9a%e6%9c%ac/</link>
		<comments>http://blog.myhnet.cn/2007/12/26/%e4%b8%80%e4%b8%aa%e6%a3%80%e6%b5%8bping%e7%bb%93%e6%9e%9c%e7%9a%84%e8%84%9a%e6%9c%ac/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 02:32:34 +0000</pubDate>
		<dc:creator>myhnet</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.myhnet.cn/?p=112</guid>
		<description><![CDATA[公司用VPN连接到丹麦的服务器，由于某些非可抗特定原因，网络不是很稳定（只是到VPN服务器），基本情况是网通快但是偶尔会掉线，电信慢，但基本上能连通。但是，网通掉线后大概三五分钟后，又会自动恢复。 这样子，每次一掉线，我就要手动去切换线路，很是麻烦。于是想写了下面这个脚本来自动完成这个过程： #!/bin/bashwhile [ 1 ] ; do&#160;&#160; &#160; &#160; &#160;ping -v -c 10 192.168.2.1 &#62; /dev/null 2&#62;&#38;1&#160;&#160; &#160; &#160; &#160;PINGSTA=$?&#160;&#160; &#160; &#160; &#160;if [ ! $PINGSTA -eq 0 ]; then&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;ip route add 202.103.96.112 via 192.168.1.1&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;/etc/init.d/openvpn restart&#160;&#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>公司用VPN连接到丹麦的服务器，由于某些非可抗特定原因，网络不是很稳定（只是到VPN服务器），基本情况是网通快但是偶尔会掉线，电信慢，但基本上能连通。但是，网通掉线后大概三五分钟后，又会自动恢复。<br />
这样子，每次一掉线，我就要手动去切换线路，很是麻烦。于是想写了下面这个脚本来自动完成这个过程：</p>
<div class="hl-surround"><div class="hl-main">#!/bin/bash<br />while [ 1 ] ; do<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ping -v -c 10 192.168.2.1 &gt; /dev/null 2&gt;&amp;1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;PINGSTA=$?<br /><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if [ ! $PINGSTA -eq 0 ]; then<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ip route add 202.103.96.112 via 192.168.1.1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/etc/init.d/openvpn restart<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sleep 300<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;fi<br /><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;route |grep '202.103.96.112' &gt; /dev/null 2&gt;&amp;1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ROUSTA=$?<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if [ $ROUSTA -eq 0 ] ; then<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ip route del 202.103.96.112 via 192.168.1.1<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/etc/init.d/openvpn restart<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sleep 30<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;fi<br />done</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.myhnet.cn/2007/12/26/%e4%b8%80%e4%b8%aa%e6%a3%80%e6%b5%8bping%e7%bb%93%e6%9e%9c%e7%9a%84%e8%84%9a%e6%9c%ac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
