<?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; debug</title>
	<atom:link href="http://bluehua.org/tag/debug/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Fri, 27 Aug 2010 08:41:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>vim里快速调试PHP</title>
		<link>http://bluehua.org/2010/07/28/1407.html</link>
		<comments>http://bluehua.org/2010/07/28/1407.html#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:10:18 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://bluehua.org/2010/07/28/1407.html</guid>
		<description><![CDATA[恩，python中一般会把调试代码跟普通代码混在一块

class xx:
#    .....
if __name__ == '__main__':
    testxx = xx&#40;&#41;
    #测试代码....

这个__name__ == &#8216;__main__&#8217;判断此文件是否被直接执行，而不是被其他文件import,所以在vim中调试时可以直接输入:!python % 执行当前正在编辑的文件,调试代码便会执行并输出结果
php也可以这么加调试代码,php中是这么实现的

class xx &#123;
// ......
&#125;
//确定当前被执行的文件就是自己,而不是被其他php文件包含
if &#40;realpath&#40;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41; == __FILE__&#41;
&#123;
    $testxx = new xx;
    //测试代码....
&#125;

如果仅限在命令行运行测试代码就再加个条件

if &#40;php_sapi_name&#40;&#41; == 'cli' &#38;&#38; realpath&#40;$_SERVER&#91;'SCRIPT_FILENAME'&#93;&#41; == __FILE__&#41;

为了更速度，vim配置里添加了一个快捷键F5

&#34;php和python调试快捷键
au FileType php map &#60;F5&#62; :call DebugRun&#40;'php'&#41;&#60;cr&#62;
au FileType php [...]]]></description>
			<content:encoded><![CDATA[<p>恩，python中一般会把调试代码跟普通代码混在一块</p>

<div class="wp_syntax"><div class="code overflow"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> xx:
<span style="color: #808080; font-style: italic;">#    .....</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    testxx = xx<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;">#测试代码....</span></pre></div></div>

<p>这个__name__ == &#8216;__main__&#8217;判断此文件是否被直接执行，而不是被其他文件import,所以在vim中调试时可以直接输入:!python % 执行当前正在编辑的文件,调试代码便会执行并输出结果</p>
<p>php也可以这么加调试代码,php中是这么实现的</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> xx <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// ......</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//确定当前被执行的文件就是自己,而不是被其他php文件包含</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$testxx</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> xx<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//测试代码....</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>如果仅限在命令行运行测试代码就再加个条件</p>

<div class="wp_syntax"><div class="code overflow"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">php_sapi_name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'cli'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>为了更速度，vim配置里添加了一个快捷键F5</p>

<div class="wp_syntax"><div class="code overflow"><pre class="vim" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">&quot;php和python调试快捷键</span>
au FileType php <span style="color: #25BB4D;">map</span> <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'php'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType php imap <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">&lt;</span>Esc<span style="color: #000000;">&gt;:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'php'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType python <span style="color: #25BB4D;">map</span> <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'python'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
au FileType python imap <span style="color: #000000;">&lt;</span>F5<span style="color: #000000;">&gt;</span> <span style="color: #000000;">&lt;</span>Esc<span style="color: #000000;">&gt;:</span><span style="color: #804040;">call</span> DebugRun<span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'python'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&lt;</span>cr<span style="color: #000000;">&gt;</span>
<span style="color: #804040;">function</span> DebugRun<span style="color: #000000;">&#40;</span>cmd<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">:</span>w
    <span style="color: #804040;">execute</span> <span style="color: #C5A22D;">'!'</span> <span style="color: #000000;">.</span> a<span style="color: #000000;">:</span>cmd <span style="color: #000000;">.</span> <span style="color: #C5A22D;">' %'</span>
endfunction</pre></div></div>

<p>OK,写完调试代码按下F5立刻有结果。</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
post by gmail~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/07/28/1407.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php整型溢出导致的小问题~</title>
		<link>http://bluehua.org/2010/03/29/1046.html</link>
		<comments>http://bluehua.org/2010/03/29/1046.html#comments</comments>
		<pubDate>Mon, 29 Mar 2010 15:58:20 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=1046</guid>
		<description><![CDATA[今天把一直本地测试的php程序放到外网的机器跑(64位系统),没想到一个纯算数值的算法竟然得到不一样的结果,最后锁定在一个求模的操作上:$i % 4, $i在本地和server上打印出来都是434807526976, 但是求出来的结果却不一样~
原因是:
php的整型最大值为2147483647(32位系统上), 当数值赋值超过这个最大值时,变量便自动成为浮点型. 所以虽然打印出来一样,但本地打印的是一个是浮点型的$i,而server上是64位系统,整型最大值达到9223372036854775807  &#8230;. $i依然是一个整型.
取模运算的结果不一样是因为php在对数值取模运算时会把浮点数转换为整型再取模(这点就不如js了,js是可以对浮点取模运算地~)
所以本地32位系统运行的其实是: ((int) $i) % 4 即 512559680 % 4
解决方法 : 最后为了保持与其他平台的一致,强制在64系统也&#8221;溢出&#8221; : ($i &#38; 0xFFFFFFFF) % 4
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;
php也是一个比较无厘头的东西~
]]></description>
			<content:encoded><![CDATA[<p>今天把一直本地测试的php程序放到外网的机器跑(64位系统),没想到一个纯算数值的算法竟然得到不一样的结果,最后锁定在一个求模的操作上:$i % 4, $i在本地和server上打印出来都是434807526976, 但是求出来的结果却不一样~</p>
<p>原因是:<br />
php的整型最大值为2147483647(32位系统上), <strong>当数值赋值超过这个最大值时,变量便自动成为浮点型</strong>. 所以虽然打印出来一样,但本地打印的是一个是浮点型的$i,而server上是64位系统,整型最大值达到9223372036854775807  &#8230;. $i依然是一个整型.</p>
<p>取模运算的结果不一样是因为<strong>php在对数值取模运算时会把浮点数转换为整型再取模</strong>(这点就不如js了,js是可以对浮点取模运算地~)</p>
<p>所以本地32位系统运行的其实是: ((int) $i) % 4 即 512559680 % 4</p>
<p>解决方法 : 最后为了保持与其他平台的一致,强制在64系统也&#8221;溢出&#8221; : ($i &amp; 0xFFFFFFFF) % 4</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>php也是一个比较无厘头的东西~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/03/29/1046.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ie下暴力debug js</title>
		<link>http://bluehua.org/2010/02/25/976.html</link>
		<comments>http://bluehua.org/2010/02/25/976.html#comments</comments>
		<pubDate>Thu, 25 Feb 2010 09:03:43 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=976</guid>
		<description><![CDATA[ie下的脚本错误总是很神秘的样子,告诉你哪个行,确不告诉你哪个文件,Visual Studio带了一个调试工具倒是可以,long long ago之前用过一次,老崩溃的样子~
如果你又遇到了猜不透的bug,可以尝试下面的shell~

//现去firefox里收集一份js列表
var alljs = &#91;&#93;;
XN.array.each&#40;document.getElementsByTagName&#40;'script'&#41;,function&#40;i,v&#41;
&#123;
    if &#40;v.src&#41;
    &#123;
        alljs.push&#40;v.src&#41;;
    &#125;
&#125;&#41;;
console.log&#40;alljs.join&#40;'\n'&#41;&#41;;

把列表保存到一个文件,下面跑段shell,把所有js的报错位置的代码打印出来

// 10 100是ie里提示的错误位置
sh ~/bin/get_line.sh /tmp/jslist 10 100

附:

#!/bin/sh
LIST=&#34;$1&#34;
ROW=&#34;$2&#34;
COL=&#34;$3&#34;
&#160;
if &#91; ! -n &#34;$ROW&#34; &#93;;then
    exit
fi
&#160;
echo &#34;行:${ROW}&#34;
echo &#34;列:${COL}&#34;
&#160;
get_row&#40;&#41;
&#123;
    cat /tmp/js_debug_tmp &#124; sed -n &#34;${ROW}p&#34;
&#125;
&#160;
cat &#34;$LIST&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>ie下的脚本错误总是很神秘的样子,告诉你哪个行,确不告诉你哪个文件,Visual Studio带了一个调试工具倒是可以,long long ago之前用过一次,老崩溃的样子~<br />
如果你又遇到了猜不透的bug,可以尝试下面的shell~</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//现去firefox里收集一份js列表</span>
<span style="color: #003366; font-weight: bold;">var</span> alljs <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
XN.<span style="color: #660066;">array</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span>v<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v.<span style="color: #660066;">src</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        alljs.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>v.<span style="color: #660066;">src</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>alljs.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>把列表保存到一个文件,下面跑段shell,把所有js的报错位置的代码打印出来</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">//</span> <span style="color: #000000;">10</span> <span style="color: #000000;">100</span>是ie里提示的错误位置
<span style="color: #c20cb9; font-weight: bold;">sh</span> ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>get_line.sh <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jslist <span style="color: #000000;">10</span> <span style="color: #000000;">100</span></pre></div></div>

<p>附:</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">LIST</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
<span style="color: #007800;">ROW</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
<span style="color: #007800;">COL</span>=<span style="color: #ff0000;">&quot;$3&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ROW</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;行:<span style="color: #007800;">${ROW}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;列:<span style="color: #007800;">${COL}</span>&quot;</span>
&nbsp;
get_row<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>js_debug_tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ROW}</span>p&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LIST</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>js_debug_tmp 
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;文件:<span style="color: #007800;">${line}</span>&quot;</span>
    <span style="color: #007800;">row</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`get_row`</span>&quot;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${COL}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">row</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`echo \&quot;${row}\&quot; | cut -c ${COL}- `</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$row</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>js_debug_tmp</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/02/25/976.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>还原用户环境失败&#8230;</title>
		<link>http://bluehua.org/2010/01/29/914.html</link>
		<comments>http://bluehua.org/2010/01/29/914.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:38:53 +0000</pubDate>
		<dc:creator>小鹿</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=914</guid>
		<description><![CDATA[话说昨天采集了用户的系统和软件信息,今天用虚拟机还原了一个,但是失败了,bug没有重现~
过程还是挺费功夫的:
首先用户用的番茄花园xp sp2, 虚拟机里用迅雷秒杀了,超赞公司网速~
Virtualbox里系统装好,下面就是比较头疼的,按照补丁列表打补丁&#8230;

hualu@lu-hua:patch$ cat /tmp/allsofts.txt &#124; grep -E &#34;\(KB[0-9]{6}&#34; &#124; sed -e 's/.*(\(KB[^)]*\).*/\1/' &#124; wc -l
138

软件列表里一共有138个补丁, 对着列表在360卫士里挨个找着选的话估计我这老眼就废了&#8230;
还是自己写脚本去微软下载

#!/bin/sh
&#160;
ID=&#34;$1&#34;
if &#91; ! -n &#34;$ID&#34; &#93;;then
    exit
fi
echo '-----------------------------------'
BASEURL='http://www.microsoft.com'
&#160;
get_first_link&#40;&#41;
&#123;
   cat &#34;$1&#34; &#124; grep &#34;Windows XP&#34; &#124; grep &#34;&#60;a&#34; &#124; sed -e 's/.*href=&#34;\([^&#34;]*\)&#34;.*/\1/' \
       -e 's/.*;u=//' \
    [...]]]></description>
			<content:encoded><![CDATA[<p>话说昨天采集了用户的系统和软件信息,今天用虚拟机还原了一个,但是失败了,bug没有重现~</p>
<p>过程还是挺费功夫的:<br />
首先用户用的番茄花园xp sp2, 虚拟机里用迅雷秒杀了,超赞公司网速~<br />
Virtualbox里系统装好,下面就是比较头疼的,按照补丁列表打补丁&#8230;</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;">hualu<span style="color: #000000; font-weight: bold;">@</span>lu-hua:<span style="color: #c20cb9; font-weight: bold;">patch</span>$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>allsofts.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-E</span> <span style="color: #ff0000;">&quot;\(KB[0-9]{6}&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/.*(\(KB[^)]*\).*/\1/'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span>
<span style="color: #000000;">138</span></pre></div></div>

<p>软件列表里一共有138个补丁, 对着列表在360卫士里挨个找着选的话估计我这老眼就废了&#8230;</p>
<p>还是自己写脚本去微软下载</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">ID</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ID</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'-----------------------------------'</span>
<span style="color: #007800;">BASEURL</span>=<span style="color: #ff0000;">'http://www.microsoft.com'</span>
&nbsp;
get_first_link<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
   <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;Windows XP&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;&lt;a&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/.*href=&quot;\([^&quot;]*\)&quot;.*/\1/'</span> \
       <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/.*;u=//'</span> \
       <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/%2f/\//g'</span> \
       <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/%3f/\?/g'</span> \
       <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/%3d/\=/g'</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_second_link<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'id=&quot;quickCheck&quot;'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/.*window\.open('\([^']*\)',.*/\1/&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">url</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${BASEURL}</span>/downloads/results.aspx?pocId=7&amp;freetext=<span style="color: #007800;">${ID}</span>&amp;DisplayLang=zh-cn&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${url}</span>&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${url}</span>&quot;</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>get_ms_link
&nbsp;
<span style="color: #007800;">surl</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`get_first_link /tmp/get_ms_link`</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${surl}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ID}</span>补丁不存在&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ID}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> .<span style="color: #000000; font-weight: bold;">/</span>patch_not_found.txt
    <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">surl</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${BASEURL}</span><span style="color: #007800;">${surl}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${surl}</span>&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${surl}</span>&quot;</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>get_ms_link
<span style="color: #007800;">turl</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`get_second_link /tmp/get_ms_link`</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${turl}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${turl}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ID}</span>补丁不存在&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${ID}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> .<span style="color: #000000; font-weight: bold;">/</span>patch_not_found.txt
    <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${turl}</span>&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'-----------------------------------'</span></pre></div></div>

<p>不知道微软有没有专门的补丁下载入口,不过我还是模仿我知道的方法下载了,先搜索,然后结果里找,使用:sh get_ms_patch.sh KB975467</p>
<p>然后几个老套的命令</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#取出所有补丁编号</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> allsofts.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-E</span> <span style="color: #ff0000;">&quot;\(KB[0-9]{6}&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/.*(\(KB[^)]*\).*/\1/'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>allpatch.txt
<span style="color: #666666; font-style: italic;">#下载所有补丁</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>allpatch.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-i</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hualu<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>get_ms_update.sh <span style="color: #ff0000;">&quot;{}&quot;</span>
<span style="color: #666666; font-style: italic;">#生成批量安装补丁的批处理文件</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*.exe&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-i</span> <span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-i</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;.\{} /passive /norestart&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> install.bat</pre></div></div>

<p>回到虚拟xp里,挂在网络驱动,双击install.bat,开始安装&#8230; 等我吃完午饭,补丁都装完了,灰常激动,立刻重启,打开ie,登录淫淫,进入个人主页, fuck, 没有脚本错误!!!!</p>
<p>估计今天我嘴上的泡就是因为这个起的,真上火&#8230; , 后面,我接着按照软件列表装了瑞星,offcie 2007,均没有看到我期待的脚本错误<img class="xemotion" src="http://bluehua.org/wp-content/plugins/x-emotions/emotions/msn/bofu3_14.gif" border="0" alt="" /></p>
<p>看来我得研究星座了&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/01/29/914.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.711 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-10 17:44:25 -->
