<?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>Jean - 记录成长历程 &#187; shell</title>
	<atom:link href="http://www.zhangyiqun.net/tag/shell/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zhangyiqun.net</link>
	<description>让世界更美好一点儿</description>
	<lastBuildDate>Wed, 07 Dec 2011 14:04:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Directadmin卸载不完全解决方案</title>
		<link>http://www.zhangyiqun.net/1520.html</link>
		<comments>http://www.zhangyiqun.net/1520.html#comments</comments>
		<pubDate>Thu, 30 Dec 2010 15:53:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[工作笔记]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.net/?p=1520</guid>
		<description><![CDATA[晚上突发奇想，想在服务器上部署directadmin并定制使其能够和rails同时运行。后来我发现directadmin实在封闭的太好，可定制性很低，为了避免我强行修改可能会造成不可预料的问题，最终还是决定先删除，最近实在没太多精力耗在这个上面。 官方没有提供相关的卸载工具，于是自己写了个脚本处理了一下<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>晚上突发奇想，想在服务器上部署directadmin并定制使其能够和rails同时运行。后来我发现directadmin实在封闭的太好，可定制性很低，为了避免我强行修改可能会造成不可预料的问题，最终还是决定先删除，最近实在没太多精力耗在这个上面。</p>
<p>官方没有提供相关的卸载工具，于是自己写了个脚本处理了一下<br />
<script src="https://gist.github.com/759912.js?file=gistfile1.sh"></script></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1520.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/1520.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>巨鲸音乐下载器</title>
		<link>http://www.zhangyiqun.net/1420.html</link>
		<comments>http://www.zhangyiqun.net/1420.html#comments</comments>
		<pubDate>Mon, 22 Nov 2010 13:53:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.net/?p=1420</guid>
		<description><![CDATA[晚上想下几张许巍的专辑听，电驴什么的太慢，于是上巨鲸搜了一下，发现还真有专辑下载，只是&#8230;得一首一首另存为，这体验也太差了。。。一次两次还行，不可能每次都这么浪费时间去点，于是写了个脚本专门抓巨鲸专辑用。 &#8211;limit-rate=300k 关于这个选项我要说一下，因为傻逼长宽作了限制，超过300K就自动给你断网1秒，所以为了能够持续的下载完专辑，我不得不加上这个限制。各位可根据自己的情况限制或者不限制。 使用方法zhang-matoMacBook-Pro~ $ ./top100down.sh &#8216;http://www.top100.cn/download/download.aspx?Productid=kcadnctughhdkcbogy&#8217;<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>晚上想下几张许巍的专辑听，电驴什么的太慢，于是上巨鲸搜了一下，发现还真有专辑下载，只是&#8230;得一首一首另存为，这体验也太差了。。。一次两次还行，不可能每次都这么浪费时间去点，于是写了个脚本专门抓巨鲸专辑用。<br />
<span id="more-1420"></span></p>
<p><span>&#8211;limit-rate=300k 关于这个选项我要说一下，因为傻逼长宽作了限制，超过300K就自动给你断网1秒，所以为了能够持续的下载完专辑，我不得不加上这个限制。各位可根据自己的情况限制或者不限制。</span></p>
<p>使用方法zhang-matoMacBook-Pro~ $ ./top100down.sh &#8216;http://www.top100.cn/download/download.aspx?Productid=kcadnctughhdkcbogy&#8217;</p>
<p><script src="https://gist.github.com/710012.js"> </script></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1420.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/1420.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>数据库内容格式转换</title>
		<link>http://www.zhangyiqun.net/1414.html</link>
		<comments>http://www.zhangyiqun.net/1414.html#comments</comments>
		<pubDate>Thu, 18 Nov 2010 16:40:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.net/?p=1414</guid>
		<description><![CDATA[转换成JS的可识别形式，没有现成的东西拿来就用，只能自己处理了，很麻烦。该睡觉了，有空详细展开说 y=-1;for i in `mysql -h127.0.0.1 -uroot -e &#8220;SET NAMES &#8216;utf8&#8242;;select * from room.citys&#8221; &#124; awk &#8216;{printf(&#8220;{\&#8221;CityId\&#8221;:\&#8221;%s\&#8221;,\&#8221;CityName\&#8221;:\&#8221;%s\&#8221;\n&#8221;,$1,$2) }&#8217;`; do let y+=1;echo -n $i;awk -F, &#8220;NR==$y{print $1}&#8221; aaa; done<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>转换成JS的可识别形式，没有现成的东西拿来就用，只能自己处理了，很麻烦。该睡觉了，有空详细展开说</p>
<p>y=-1;for i in `mysql -h127.0.0.1 -uroot -e &#8220;SET NAMES &#8216;utf8&#8242;;select * from room.citys&#8221; | awk &#8216;{printf(&#8220;{\&#8221;CityId\&#8221;:\&#8221;%s\&#8221;,\&#8221;CityName\&#8221;:\&#8221;%s\&#8221;\n&#8221;,$1,$2) }&#8217;`; do let y+=1;echo -n $i;awk -F, &#8220;NR==$y{print $1}&#8221; aaa; done</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1414.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/1414.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>判断命令是否存在于$PATH中</title>
		<link>http://www.zhangyiqun.net/1109.html</link>
		<comments>http://www.zhangyiqun.net/1109.html#comments</comments>
		<pubDate>Tue, 04 May 2010 12:33:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux系统]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.net/?p=1109</guid>
		<description><![CDATA[一 [jean@jeantoe /]$ command -v ls &#62;/dev/null &#38;&#38; echo &#8220;command Found In \$PATH&#8221; &#124;&#124; echo &#8220;command Not Found in \$PATH&#8221; command1 Found In $PATH [jean@jeantoe /]$ command -v ss &#62;/dev/null &#38;&#38; echo &#8220;command Found In \$PATH&#8221; &#124;&#124; echo &#8220;command Not Found in \$PATH&#8221; command Found In $PATH 二 [jean@jeantoe /]$ type -P command1 &#38;&#62;/dev/null &#38;&#38; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>一</p>
<p>[jean@jeantoe /]$ command -v ls &gt;/dev/null &amp;&amp; echo &#8220;command Found In \$PATH&#8221; || echo &#8220;command Not Found in \$PATH&#8221;<br />
command1 Found In $PATH<br />
[jean@jeantoe /]$ command -v ss &gt;/dev/null &amp;&amp; echo &#8220;command Found In \$PATH&#8221; || echo &#8220;command Not Found in \$PATH&#8221;<br />
command Found In $PATH</p>
<p>二</p>
<p>[jean@jeantoe /]$ type -P command1 &amp;&gt;/dev/null &amp;&amp; echo &#8220;Found&#8221; || echo &#8220;Not Found&#8221;<br />
Not Found</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1109.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/1109.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell技巧分享</title>
		<link>http://www.zhangyiqun.net/1081.html</link>
		<comments>http://www.zhangyiqun.net/1081.html#comments</comments>
		<pubDate>Sat, 03 Apr 2010 09:48:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.net/?p=1081</guid>
		<description><![CDATA[cp filename{,.bak} 快速备份 ssh-copy-id user@host 将 ssh keys 复制到 user@host 以启用无密码 SSH 登录。 ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg 把 Linux 桌面录制为视频。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>cp filename{,.bak}</p>
<p>快速备份</p>
<p>ssh-copy-id user@host</p>
<p>将 ssh keys 复制到 user@host 以启用无密码 SSH 登录。</p>
<p>ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg</p>
<p>把 Linux 桌面录制为视频。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/1081.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>监控服务器日志滚动</title>
		<link>http://www.zhangyiqun.net/682.html</link>
		<comments>http://www.zhangyiqun.net/682.html#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:33:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux系统]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=682</guid>
		<description><![CDATA[需求 完成一个 java日志监控脚本, 发现10分钟日志不滚动就发送报警邮件和报警短 信. 日志地址: web1-4 的 /home/test/software/java/Jtest/log/*/M.log 邮件报警标题 [监控][JAVA]未滚动日志列表 [20090907_125901] 发给xxx 思路 tail 日志的最后3-10行. 算出md5sum值. 对比前后两次是否一致, 如果一致就说明有问题. ?View Code SHELL#!/bin/bash #转载请注明出处，谢谢合作 #writen by jeantoe #jeantoe@gmail.com #2009/09/08 &#160; #Information sendtime=`date +%Y%m%d_%H%M%S` MAIL='jeantoe@gmail.com' MAILFILE='/usr/local/nagios/toJAVAmail' #MBS='your cell phone number' &#160; HOSTLIST='web1 web2 web3 web4' FILES=' test.osgi.common test.osgi.core.buy test.osgi.core.follow test.osgi.service.buy test.osgi.core.lottery test.osgi.core.lottery.analyzer test.osgi.core.notify test.osgi.ice.buy.server test.osgi.core.s2m test.osgi.core.schedule test.osgi.core.tds [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>需求</p>
<p>完成一个 java日志监控脚本, 发现10分钟日志不滚动就发送报警邮件和报警短<br />
信.</p>
<p>日志地址: web1-4 的<br />
/home/test/software/java/Jtest/log/*/M.log</p>
<p>邮件报警标题<br />
[监控][JAVA]未滚动日志列表 [20090907_125901] 发给xxx</p>
<p>思路</p>
<p>tail 日志的最后3-10行. 算出md5sum值. 对比前后两次是否一致, 如果一致就说明有问题.</p>
<p><span id="more-682"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p682code2'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6822"><td class="code" id="p682code2"><pre class="shell" style="font-family:monospace;">#!/bin/bash
#转载请注明出处，谢谢合作
#writen by jeantoe
#jeantoe@gmail.com
#2009/09/08
&nbsp;
#Information
sendtime=`date +%Y%m%d_%H%M%S`
MAIL='jeantoe@gmail.com'
MAILFILE='/usr/local/nagios/toJAVAmail'
#MBS='your cell phone number'
&nbsp;
HOSTLIST='web1 web2 web3 web4'
FILES='
test.osgi.common
test.osgi.core.buy
test.osgi.core.follow
test.osgi.service.buy
test.osgi.core.lottery
test.osgi.core.lottery.analyzer
test.osgi.core.notify
test.osgi.ice.buy.server
test.osgi.core.s2m
test.osgi.core.schedule
test.osgi.core.tds
'
FILESNUMBER=11
COMMANDLOG='tail -n 3'
SLEEP_SEC=600
&nbsp;
#collect A
for i in $HOSTLIST
do
 /usr/bin/ssh $i &quot;
   echo &quot;start $i &quot; &amp;gt; /logs/javalog/$i.a.all
 &quot;
 for b in $FILES
  do
   /usr/bin/ssh $i &quot;
    $COMMANDLOG /home/test/software/java/Jtest/log/${b}/M.log &amp;gt; /logs/javalog/$i.a.${b}
    /usr/bin/md5sum /logs/javalog/$i.a.${b}| sed &quot;s@$i.a.${b}@$i.${b}@&quot; &amp;gt;&amp;gt; /logs/javalog/$i.a.all
    scp /logs/javalog/$i.a.all test00:/logs/javalog
  &quot;
  done
done
&nbsp;
#sleep $SLEEP_SEC
&nbsp;
#collect B
for i in $HOSTLIST
do
  /usr/bin/ssh $i &quot;
   echo &quot;start $i &quot; &amp;gt; /logs/javalog/$i.b.all
 &quot;
 for b in $FILES
  do
   /usr/bin/ssh $i &quot;
    $COMMANDLOG /home/test/software/java/Jtest/log/${b}/M.log &amp;gt; /logs/javalog/$i.b.${b}
    echo &quot;start $i &quot; &amp;gt; $i.b.all
    /usr/bin/md5sum /logs/javalog/$i.b.${b}| sed &quot;s@$i.b.${b}@$i.${b}@&quot; &amp;gt;&amp;gt; /logs/javalog/$i.b.all
    scp /logs/javalog/$i.b.all test00:/logs/javalog
  &quot;
  done
done
&nbsp;
#send mail
&nbsp;
echo &quot;To: $MAIL&quot; &amp;gt;$MAILFILE
echo &quot;From: autopost@gmail.com&quot; &amp;gt;&amp;gt;$MAILFILE
echo &quot;Subject: [Monitor][JAVA]未滚动日志列表[$sendtime] &quot; &amp;gt;&amp;gt; $MAILFILE
for i in $HOSTLIST
do
   a_ALL=`cat  /logs/javalog/$i.a.all | wc -l`
   b_ALL=`cat  /logs/javalog/$i.b.all | wc -l`
   DIFF=`diff -y --suppress-common-lines /logs/javalog/$i.a.all /logs/javalog/$i.b.all | wc -l`
   if (( $a_ALL != $b_ALL ));then
    echo &quot;${i}日志文件错误&quot;
   elif (( $DIFF &amp;lt;= $FILESNUMBER ));then
    echo &quot;THIS IS ${i}&quot; &amp;gt;&amp;gt; $MAILFILE
    echo &quot;JAVA日志十分钟没滚了,赶紧踢他一脚&quot; &amp;gt;&amp;gt; $MAILFILE
    for x in `awk '$1 ~ /[^start]/{print $1}' /logs/javalog/$i.a.all`
      do
       grep $x /logs/javalog/$i.b.all | sed 's@\(.*\)\(/logs/javalog/web...\)\(.*\)@/home/test/software/java/Jtest/log/\3/M.log \1@'&amp;gt;&amp;gt; $MAILFILE
      done
    echo &quot;             &quot;&amp;gt;&amp;gt; $MAILFILE
#   此处可插入手机短信通知
   else
     exit 0
   fi
done
cat $MAILFILE | /usr/lib/sendmail -t</pre></td></tr></table></div>

<p>脚本写的很一般，偷懒了，变量不太规范可能除了我没人能对它修改了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F682.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/682.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>过滤大于200秒的慢查询</title>
		<link>http://www.zhangyiqun.net/630.html</link>
		<comments>http://www.zhangyiqun.net/630.html#comments</comments>
		<pubDate>Wed, 26 Aug 2009 12:03:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[工作笔记]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=630</guid>
		<description><![CDATA[日志格式 # User@Host: root[root] @ svr56.okooo [192.168.8.56] # Query_time: 44 Lock_time: 0 Rows_sent: 0 Rows_examined: 0 /*!40000 ALTER TABLE `TogetherBuyTop` ENABLE KEYS */; # Time: 090825 1:52:41 # User@Host: root[root] @ svr56.okooo [192.168.8.56] # Query_time: 255 Lock_time: 0 Rows_sent: 0 Rows_examined: 0 &#8211; SELECT SponsorName,LotteryType,LotteryNo,SingleMulti,ConsignType,ProjectID,SponsorID,TotalMoney,RawPrize,Status FROM NewProject WHERE LotteryType = &#8216;WDL&#8217; AND SponsorID = &#8217;174760&#8242; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>日志格式</p>
<p><span id="more-630"></span></p>
<blockquote><p># User@Host: root[root] @ svr56.okooo [192.168.8.56]<br />
# Query_time: 44  Lock_time: 0  Rows_sent: 0  Rows_examined: 0<br />
/*!40000 ALTER TABLE `TogetherBuyTop` ENABLE KEYS */;<br />
# Time: 090825  1:52:41<br />
# User@Host: root[root] @ svr56.okooo [192.168.8.56]<br />
# Query_time: 255  Lock_time: 0  Rows_sent: 0  Rows_examined: 0</p>
<p>&#8211;<br />
SELECT SponsorName,LotteryType,LotteryNo,SingleMulti,ConsignType,ProjectID,SponsorID,TotalMoney,RawPrize,Status FROM NewProject WHERE LotteryType = &#8216;WDL&#8217;  AND SponsorID = &#8217;174760&#8242; AND ConsignType = &#8216;Together&#8217;   Order By ProjectID DESC  LIMIT 0,50;<br />
# User@Host: root[root] @ svr34.okooo [192.168.8.34]<br />
# Query_time: 3  Lock_time: 0  Rows_sent: 309  Rows_examined: 101341<br />
SELECT DISTINCT TableItem FROM ArenaTable WHERE TableType = &#8216;LotteryNo&#8217; ORDER BY TableItem DESC;<br />
# User@Host: root[root] @ svr36.okooo [192.168.8.36]<br />
# Query_time: 255  Lock_time: 0  Rows_sent: 0  Rows_examined: 0<br />
# Time: 090825 11:37:53<br />
# User@Host: root[root] @ svr30.okooo [192.168.8.30]<br />
# Query_time: 5  Lock_time: 0  Rows_sent: 50  Rows_examined: 601<br />
SELECT SponsorName,LotteryType,LotteryNo,SingleMulti,ConsignType,ProjectID,SponsorID,TotalMoney,RawPrize,Status FROM NewProject WHERE LotteryType = &#8216;ToTo&#8217;  AND SponsorID = &#8217;206226&#8242; AND ConsignType = &#8216;Together&#8217;   Order By ProjectID DESC  LIMIT 0,50;<br />
# User@Host: root[root] @ svr34.okooo [192.168.8.34]<br />
# Query_time: 237  Lock_time: 0  Rows_sent: 0  Rows_examined: 0<br />
&#8211;<br />
SELECT T1.MatchID,T1.MakerID,T3.MakerCnName,T1.HandicapNumber,T2.HandicapName,OverLine,UnderLine,HandicapType,T1.LastTime<br />
FROM MatchHandicap AS T1 LEFT JOIN HandicapType AS T2 ON T1.HandicapNumber = T2.HandicapNumber<br />
LEFT JOIN BookMaker AS T3 ON T1.MakerID=T3.MakerID</p></blockquote>
<p>几个注意事项</p>
<p>为了不漏掉可能的查询，我显示了匹配行的下5行。</p>
<p>grep 无法直接 awk &#8216;$2 ~ /Query_time/{if ($3&gt;=200){print $2,$3}}&#8217; /logs/mysql/slow.log ，因为换行符？</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p630code4'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p6304"><td class="code" id="p630code4"><pre class="shell" style="font-family:monospace;">#!/bin/bash
for i in `awk '$2 ~ /Query_time/{if ($3&amp;gt;=200){print $3}}' /logs/mysql/slow.log`
do
        grep -B 5 &quot;Query_time: $i&quot; /logs/mysql/slow.log
done</pre></td></tr></table></div>

<p><span style="color: #ff0000;">grep 打印上下文5行</span></p>
<p><span style="color: #ff0000;">grep -A 5 -B 5</span></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F630.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/630.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>expect+ssh实现无人值守批量管理</title>
		<link>http://www.zhangyiqun.net/485.html</link>
		<comments>http://www.zhangyiqun.net/485.html#comments</comments>
		<pubDate>Fri, 10 Jul 2009 12:28:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux系统]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=485</guid>
		<description><![CDATA[和我一起进公司的几个应届都给安排了不错的技术活让练手，让我负责解决客户问题无法访问网站问题，整理机器硬件信息然后录入公司网站，纯体力劳动。或许是因为有学历？这高中退学的小子不如大学毕业的有培养价值，即使是一个烂大学。 废话不多说，简单描述下情况：公司共有40台服务器，硬件配置都不一样。需要统计出每个服务器的硬件配置，网络参数，计划任务，软件环境，用户，负载情况，BIOS以及机器序列号。 首先要实现的是自动登录，我对tcl并不熟悉，所以只是初步实现了功能，很多细节没有考虑。（比如有些机器是不允许登录ftp的，事后我又专门写了一个scp的脚本解决这个问题）。里面的info.sh是我统计机器信息时候用的，请根据需要替换成自己的脚本。 ?View Code EXPECT#!/usr/bin/expect -f set ipaddr [lrange $argv 0 0] #ip参数 spawn ssh -p 9922 -o StrictHostKeyChecking=no $ipaddr expect &#34;*?assword:*&#34; sleep 3 send &#34;123\r&#34; #密码 &#160; expect &#34;]#&#34; send &#34;rm -rf /root/info.sh\r&#34; &#160; expect &#34;]#&#34; send &#34;rm -rf /root/toftp/*\r&#34; &#160; expect &#34;]#&#34; send &#34;wget www.zhangyiqun.cn/hard.sh\r&#34; sleep 3 &#160; expect &#34;]#&#34; send &#34;chmod [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>和我一起进公司的几个应届都给安排了不错的技术活让练手，让我负责解决客户问题无法访问网站问题，整理机器硬件信息然后录入公司网站，纯体力劳动。或许是因为有学历？这高中退学的小子不如大学毕业的有培养价值，即使是一个烂大学。</p>
<p>废话不多说，简单描述下情况：公司共有40台服务器，硬件配置都不一样。需要统计出每个服务器的硬件配置，网络参数，计划任务，软件环境，用户，负载情况，BIOS以及机器序列号。</p>
<p><span id="more-485"></span><br />
首先要实现的是自动登录，我对tcl并不熟悉，所以只是初步实现了功能，很多细节没有考虑。（比如有些机器是不允许登录ftp的，事后我又专门写了一个scp的脚本解决这个问题）。里面的info.sh是我统计机器信息时候用的，请根据需要替换成自己的脚本。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p485code7'); return false;">View Code</a> EXPECT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4857"><td class="code" id="p485code7"><pre class="expect" style="font-family:monospace;">#!/usr/bin/expect -f
set ipaddr [lrange $argv 0 0] #ip参数
spawn ssh -p 9922 -o StrictHostKeyChecking=no $ipaddr
expect &quot;*?assword:*&quot;
sleep 3
send &quot;123\r&quot; #密码
&nbsp;
expect &quot;]#&quot;
send &quot;rm -rf /root/info.sh\r&quot;
&nbsp;
expect &quot;]#&quot;
send &quot;rm -rf /root/toftp/*\r&quot;
&nbsp;
expect &quot;]#&quot;
send &quot;wget www.zhangyiqun.cn/hard.sh\r&quot;
sleep 3
&nbsp;
expect &quot;]#&quot;
send &quot;chmod +x info.sh\r&quot;
&nbsp;
expect &quot;]#&quot;
send &quot;/root/info.sh\r&quot;
&nbsp;
expect &quot;]#&quot;
send &quot;cd /root/toftp\r&quot;
&nbsp;
expect &quot;]#&quot;
send &quot;ftp 72.167.232.88\r&quot;
sleep 2
&nbsp;
expect &quot;Name (72.167.232.191:root):&quot;
send &quot;zhangyiqun\r&quot;
sleep 2
&nbsp;
expect &quot;Password:&quot;
send &quot;123\r&quot;
sleep 3
&nbsp;
expect &quot;ftp&gt;&quot;
send &quot;cd data\r&quot;
sleep 3
&nbsp;
expect &quot;ftp&gt;&quot;
send &quot;put *\r&quot;
sleep 8
&nbsp;
expect eof</pre></td></tr></table></div>

<p>现在来实现ip传递</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p485code8'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4858"><td class="code" id="p485code8"><pre class="shell" style="font-family:monospace;">#!/bin/bash
for i in `awk '{print $1}' /root/Download/ipaddr`
do
/root/Download/dele.sh $i
done</pre></td></tr></table></div>

<p>我把ip放在了ipaddr，可以自动读取。因为我们的服务器密码都一样所以我在expect中直接把密码设成了123 。也许以后会遇到多个服务器密码不同的问题，那也不复杂，将密码放入ipaddr用awk截取即可。</p>
<p>#本人长期寻找好活（兼职亦可），如果有的话请朋友们推荐一下啦～</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F485.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/485.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>shell面试题一个，对比小数大小</title>
		<link>http://www.zhangyiqun.net/333.html</link>
		<comments>http://www.zhangyiqun.net/333.html#comments</comments>
		<pubDate>Tue, 28 Apr 2009 14:20:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=333</guid>
		<description><![CDATA[帮朋友写的，功能是监视top中的cpu使用，这题比较冷门的是shell中小数的对比。 ?View Code SHELL#!/bin/bash while : do top -d 30 -b -n 1 &#62; /root/top1 top -d 60 -b -n 1 &#62; /root/top2 BEFORE=`awk 'NR==3{print $2}' /root/top1 &#124; sed -n 's/[^0-9.]//gp'` AFTER=`awk 'NR==3{print $2}' /root/top2 &#124; sed -n 's/[^0-9.]//gp'` expr $BEFORE \&#62; $AFTER &#38;&#62;/dev/null if (( $? == 1 )) then echo $AFTER&#62;/tmp/now fi &#38;&#38; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>帮朋友写的，功能是监视top中的cpu使用，这题比较冷门的是shell中小数的对比。<br />
<span id="more-333"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p333code10'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p33310"><td class="code" id="p333code10"><pre class="shell" style="font-family:monospace;">#!/bin/bash
while :
do
top -d 30 -b -n 1 &gt; /root/top1
top -d 60 -b -n 1 &gt; /root/top2
BEFORE=`awk 'NR==3{print $2}' /root/top1 | sed -n 's/[^0-9.]//gp'`
AFTER=`awk 'NR==3{print $2}' /root/top2 | sed -n 's/[^0-9.]//gp'`
expr $BEFORE \&gt; $AFTER &amp;&gt;/dev/null
if (( $? == 1 ))
then
        echo $AFTER&gt;/tmp/now
fi &amp;&amp; break
done
exit 0</pre></td></tr></table></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/333.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>bash中的$</title>
		<link>http://www.zhangyiqun.net/164.html</link>
		<comments>http://www.zhangyiqun.net/164.html#comments</comments>
		<pubDate>Fri, 27 Mar 2009 12:13:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=164</guid>
		<description><![CDATA[$0  脚本名  $#  位置参量个数  $*  所有的位置参量  $@  未加双引号时，与$*的含义相同  &#8220;$*&#8221;  单个变量(例如：&#8221;$1 $2 $3&#8243;)  &#8220;$@&#8221;  多个单独的变量(例如：&#8221;$1&#8243; &#8220;$2&#8243; &#8220;$3&#8243;)  $1 … ${10}  单独的位置参量<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角1</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>$0  脚本名 </p>
<p>$#  位置参量个数 </p>
<p>$*  所有的位置参量 </p>
<p>$@  未加双引号时，与$*的含义相同 </p>
<p>&#8220;$*&#8221;  单个变量(例如：&#8221;$1 $2 $3&#8243;) </p>
<p>&#8220;$@&#8221;  多个单独的变量(例如：&#8221;$1&#8243; &#8220;$2&#8243; &#8220;$3&#8243;) </p>
<p>$1 … ${10}  单独的位置参量</p>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://www.zhangyiqun.net";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=4&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress3.2.1";
    //--></script><script type="text/javascript" src="http://widget.wumii.com/ext/relatedItemsWidget.htm"></script><a href="http://www.wumii.com/widget/relatedItems.htm" style="border:0;"><img src="http://static.wumii.com/images/pixel.png" alt="无觅相关文章插件，快速提升流量" style="border:0;padding:0;margin:0;" /></a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角1</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/164.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.zhangyiqun.net @ 2012-02-07 22:37:53 -->
