﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-淡泊明志、宁静致远-随笔分类-工作随笔</title><link>http://www.cnitblog.com/houcy/category/6989.html</link><description>A Diamond is just a piece of Coal that did well under Pressure.</description><language>zh-cn</language><lastBuildDate>Mon, 18 Mar 2013 02:57:37 GMT</lastBuildDate><pubDate>Mon, 18 Mar 2013 02:57:37 GMT</pubDate><ttl>60</ttl><item><title>反汇编心得</title><link>http://www.cnitblog.com/houcy/archive/2013/03/16/87075.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sat, 16 Mar 2013 07:09:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2013/03/16/87075.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/87075.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2013/03/16/87075.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/87075.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/87075.html</trackback:ping><description><![CDATA[看汇编代码时一定要牢牢把握栈的变化情况，脑里浮现栈帧图，并时刻跟踪ESP，这样会更容易读懂汇编。<br /><br />下面是函数调用时callee要做的事情（被调用者负责平衡堆栈: 分配和释放栈空间），所有的函数本质上都是callee，由别的函数调用指行，包括main函数：<br /><br />1. 保存旧的帧指针（把新的栈帧链接到栈帧链表中）<br />其实栈被分成一个个连续的栈帧(由于函数调用的原因)，这些栈帧就像链表一样被EBP链接了起来，每次被调用函数callee要做的第一件事情就是把新的栈帧链接到原来的栈帧链表上，即汇编代码:<br />&nbsp;push ebp<br />把EBP的值压栈，而EBP恰是caller函数的帧指针，这就相当于挂接到栈帧链表上。<br /><br />2. 建立新的帧指针<br />&nbsp;mov&nbsp; ebp ,&nbsp;esp<br /><br />3. 分配新的栈空间<br />sub esp , 0xC0h<br /><br />4. 把寄存器压栈<br />push ebx<br />push esi<br />push edi<br /><br />5. 初始化栈空间<br />初始化栈空间为0xCCh，<span lang="EN-US" xml:lang="EN-US">0xCCh</span>是汇编指令<span lang="EN-US" xml:lang="EN-US">int 3</span>的二进制码，便于中断纠错。<br />lea edi , [ebp - 0xC0h]<br />mov ecx , 30h&nbsp; ;长度，30h * 4 = 0xC0h<br />mov eax , 0xCCCCCCCCh <br />rep stosd<br /><br />6. 执行函数的算法代码<br /><br />7. 平衡堆栈：弹出保存的寄存器，恢复栈空间，恢复被保存的EBP，即从栈帧链表中删除callee的栈帧。<br />pop edi<br />pop esi<br />pop ebx<br />mov esp , ebp ;恢复栈空间，重置栈顶esp, 此时esp = ebp = 旧的ebp<br />pop ebp ;恢复旧的EBP，即把新的栈帧从栈帧链表中删除了，此时esp指向被保存的函数返回地址，即call之后的地址<br />retn&nbsp; ; 函数返回，此指令相当于pop eip，把esp指向的函数返回地址赋值给EIP<br /><br />栈帧结构图：<br /><img border="0" alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/栈帧图.jpg" width="461" longdesc="" height="624" /><br /><br /><img src ="http://www.cnitblog.com/houcy/aggbug/87075.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2013-03-16 15:09 <a href="http://www.cnitblog.com/houcy/archive/2013/03/16/87075.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>matplotlib生成曲线图的python脚本</title><link>http://www.cnitblog.com/houcy/archive/2013/01/22/86938.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Tue, 22 Jan 2013 09:35:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2013/01/22/86938.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/86938.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2013/01/22/86938.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/86938.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/86938.html</trackback:ping><description><![CDATA[<p><span style="font-family: 宋体">工作中经常要分析数据，比如网络并发量，</span>DC<span style="font-family: 宋体">响应时间等，借用</span>matplotlib<span style="font-family: 宋体">将数据生成曲线图，可以直观地分析数据的变化情况。</span></p>
<p><span style="font-family: 宋体">下面是生成曲线图的脚本，实际使用时修改某些值定制一下即可。</span><br /><br /></p>
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; font-size: 12pt">&nbsp;1</span><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">!/usr/bin/env&nbsp;python</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">&nbsp;2</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;-*-&nbsp;coding:&nbsp;utf-8&nbsp;-*-</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">&nbsp;3</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">"""</span><span style="color: #800000"><br /></span><span style="color: #008080; font-size: 12pt">&nbsp;4</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">File&nbsp;Function:&nbsp;读取数据文件，生成曲线图<br /></span><span style="color: #008080; font-size: 12pt">&nbsp;5</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">data&nbsp;source&nbsp;format:<br /></span><span style="color: #008080; font-size: 12pt">&nbsp;6</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;51&nbsp;07:27:46<br /></span><span style="color: #008080; font-size: 12pt">&nbsp;7</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;106&nbsp;07:27:47<br /></span><span style="color: #008080; font-size: 12pt">&nbsp;8</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;139&nbsp;07:27:48<br /></span><span style="color: #008080; font-size: 12pt">&nbsp;9</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;326&nbsp;07:27:49<br /></span><span style="color: #008080; font-size: 12pt">10</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;185&nbsp;07:27:50<br /></span><span style="color: #008080; font-size: 12pt">11</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.cnitblog.com/Images/dot.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">..<br /></span><span style="color: #008080; font-size: 12pt">12</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">Author:&nbsp;Kevin&nbsp;Hou<br /></span><span style="color: #008080; font-size: 12pt">13</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">Date:&nbsp;2013/01/22<br /></span><span style="color: #008080; font-size: 12pt">14</span><span style="color: #800000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #800000; font-size: 12pt">"""</span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">15</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">16</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff; font-size: 12pt">import</span><span style="color: #000000; font-size: 12pt">&nbsp;matplotlib.pyplot&nbsp;as&nbsp;pl<br /></span><span style="color: #008080; font-size: 12pt">17</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff; font-size: 12pt">from</span><span style="color: #000000; font-size: 12pt">&nbsp;matplotlib.ticker&nbsp;</span><span style="color: #0000ff; font-size: 12pt">import</span><span style="color: #000000; font-size: 12pt">&nbsp;MultipleLocator,&nbsp;FuncFormatter<br /></span><span style="color: #008080; font-size: 12pt">18</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff; font-size: 12pt">import</span><span style="color: #000000; font-size: 12pt">&nbsp;numpy&nbsp;as&nbsp;np<br /></span><span style="color: #008080; font-size: 12pt">19</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">20</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">MultipleLocator.MAXTICKS&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000; font-size: 12pt">100000</span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">21</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">22</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">fig&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;pl.figure(figsize</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">(</span><span style="color: #000000; font-size: 12pt">10</span><span style="color: #000000; font-size: 12pt">,</span><span style="color: #000000; font-size: 12pt">6</span><span style="color: #000000; font-size: 12pt">))<br /></span><span style="color: #008080; font-size: 12pt">23</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">24</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">77为文件数据个数</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">25</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">x&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;np.arange(0,&nbsp;</span><span style="color: #000000; font-size: 12pt">77</span><span style="color: #000000; font-size: 12pt">,&nbsp;</span><span style="color: #000000; font-size: 12pt">1</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">26</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">y&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;[]<br /></span><span style="color: #008080; font-size: 12pt">27</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">z&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;[]<br /></span><span style="color: #008080; font-size: 12pt">28</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">t&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;[]<br /></span><span style="color: #008080; font-size: 12pt">29</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">30</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">f&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;open(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">yr_nr.txt</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">,</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">r</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">31</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">num</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">0<br /></span><span style="color: #008080; font-size: 12pt">32</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff; font-size: 12pt">for</span><span style="color: #000000; font-size: 12pt">&nbsp;l&nbsp;</span><span style="color: #0000ff; font-size: 12pt">in</span><span style="color: #000000; font-size: 12pt">&nbsp;f:<br /></span><span style="color: #008080; font-size: 12pt">33</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;y.append(int(l.strip().split(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000">&nbsp;</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)[0]))<br /></span><span style="color: #008080; font-size: 12pt">34</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">隔两个点显示一个label，否则x轴显示不下</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">35</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff; font-size: 12pt">if</span><span style="color: #000000; font-size: 12pt">&nbsp;num</span><span style="color: #000000; font-size: 12pt">%</span><span style="color: #000000; font-size: 12pt">3</span><span style="color: #000000; font-size: 12pt">==</span><span style="color: #000000; font-size: 12pt">0:<br /></span><span style="color: #008080; font-size: 12pt">36</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.append(l.strip().split(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000">&nbsp;</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)[</span><span style="color: #000000; font-size: 12pt">1</span><span style="color: #000000; font-size: 12pt">])<br /></span><span style="color: #008080; font-size: 12pt">37</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;num&nbsp;</span><span style="color: #000000; font-size: 12pt">+=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000; font-size: 12pt">1</span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">38</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">f.close()<br /></span><span style="color: #008080; font-size: 12pt">39</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.plot(x,&nbsp;y,&nbsp;label</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #800000; font-size: 12pt">YR</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #000000; font-size: 12pt">,&nbsp;color</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #800000; font-size: 12pt">red</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">40</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">41</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">f&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;open(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">kk_nr.txt</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">,</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">r</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">42</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff; font-size: 12pt">for</span><span style="color: #000000; font-size: 12pt">&nbsp;l&nbsp;</span><span style="color: #0000ff; font-size: 12pt">in</span><span style="color: #000000; font-size: 12pt">&nbsp;f:<br /></span><span style="color: #008080; font-size: 12pt">43</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;z.append(int(l.strip().split(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000">&nbsp;</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)[0]))<br /></span><span style="color: #008080; font-size: 12pt">44</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">f.close()<br /></span><span style="color: #008080; font-size: 12pt">45</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.plot(x,&nbsp;z,&nbsp;label</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #800000; font-size: 12pt">KK</span><span style="color: #800000; font-size: 12pt">'</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">46</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">47</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">ax&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;pl.gca()<br /></span><span style="color: #008080; font-size: 12pt">48</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">49</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;设置两个坐标轴的范围</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">50</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.ylim(0,</span><span style="color: #000000; font-size: 12pt">800</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">51</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.xlim(0,&nbsp;np.max(x))<br /></span><span style="color: #008080; font-size: 12pt">52</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">53</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;设置图的底边距</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">54</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.subplots_adjust(bottom&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000; font-size: 12pt">0.15</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">55</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">56</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.grid()&nbsp;</span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">开启网格</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">57</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">58</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;主刻度</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">59</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">ax.xaxis.set_major_locator(&nbsp;MultipleLocator(</span><span style="color: #000000; font-size: 12pt">3</span><span style="color: #000000; font-size: 12pt">)&nbsp;)<br /></span><span style="color: #008080; font-size: 12pt">60</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">ax.yaxis.set_major_locator(&nbsp;MultipleLocator(</span><span style="color: #000000; font-size: 12pt">50</span><span style="color: #000000; font-size: 12pt">)&nbsp;)<br /></span><span style="color: #008080; font-size: 12pt">61</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">62</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;主刻度文本用time_formatter函数计算</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">63</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">ax.xaxis.set_major_formatter(&nbsp;FuncFormatter(&nbsp;time_formatter&nbsp;)&nbsp;)</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">64</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">65</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;副刻度为</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">66</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">ax.xaxis.set_minor_locator(&nbsp;MultipleLocator(np.pi/20)&nbsp;)</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">67</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000"><br /></span><span style="color: #008080; font-size: 12pt">68</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">获取当前x轴的label</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">69</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">locs,labels&nbsp;</span><span style="color: #000000; font-size: 12pt">=</span><span style="color: #000000; font-size: 12pt">&nbsp;pl.xticks()<br /></span><span style="color: #008080; font-size: 12pt">70</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">重新设置新的label,用时间t设置</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">71</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.xticks(locs,&nbsp;t)<br /></span><span style="color: #008080; font-size: 12pt">72</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">73</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.ylabel(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">Number</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">74</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.title(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">WCG&nbsp;=&gt;&nbsp;Samba</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)<br /></span><span style="color: #008080; font-size: 12pt">75</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">76</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;设置刻度文本的大小</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">77</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">for&nbsp;tick&nbsp;in&nbsp;ax.xaxis.get_major_ticks():</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">78</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">&nbsp;&nbsp;&nbsp;&nbsp;tick.label1.set_fontsize(5)</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">79</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">pl.show()</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">80</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.legend()<br /></span><span style="color: #008080; font-size: 12pt">81</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">82</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">自动调整label显示方式，如果太挤则倾斜显示</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">83</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">fig.autofmt_xdate()<br /></span><span style="color: #008080; font-size: 12pt">84</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080; font-size: 12pt">85</span><span style="color: #000000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000; font-size: 12pt">#</span><span style="color: #008000; font-size: 12pt">保存曲线为图片格式</span><span style="color: #008000"><br /></span><span style="color: #008080; font-size: 12pt">86</span><span style="color: #008000"><img align="top" src="http://www.cnitblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000; font-size: 12pt">pl.savefig(</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #800000; font-size: 12pt">wcg.png</span><span style="color: #800000; font-size: 12pt">"</span><span style="color: #000000; font-size: 12pt">)</span></div><br />生成的曲线图：<br /><br /><img border="0" alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/wcg.png" width="1000" height="600" /><img src ="http://www.cnitblog.com/houcy/aggbug/86938.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2013-01-22 17:35 <a href="http://www.cnitblog.com/houcy/archive/2013/01/22/86938.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Django配置static文件访问，解决css样式表未被浏览器载入错误</title><link>http://www.cnitblog.com/houcy/archive/2012/12/23/86862.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sat, 22 Dec 2012 16:16:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2012/12/23/86862.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/86862.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2012/12/23/86862.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/86862.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/86862.html</trackback:ping><description><![CDATA[最近用Django为我们Team搭建HTTP Web Server时老是遇到页面布局显示凌乱，用Firebug查看了一下，有下面的错误信息，main.css样式表文件竟然没被浏览器加载，导致页面非正常显示，但是HTTP的请求和返回都是正常的。<br /><br /><div><br />[23:59:56.911] 样式表单 http://192.168.1.111:8000/static/css/main.css 未载入，因为它的MIME类型 "text/html" 不是 "text/css"。 @ http://192.168.1.111:8000/</div><div>[23:59:56.985] GET http://192.168.1.111:8000/static/css/main.css [HTTP/1.0 200 OK 15ms]</div><br /><div>查看了一下页面中确实正确地设置了"text/css"，而且HTTP返回码也是200  OK，查找了半天也没有找到原因，很是郁闷，后来直接在浏览器里尝试加载css文件，返回的竟然不是css文件内容，而是html首页内容，原来是匹配到 了url.py中的default规则了，也就是说css的路径不对，换句话说就是static文件的配置不对，原来是settings.py中 <span style="color: red;">INSTALLED_APPS</span>中把<span style="color: red;">staticfiles</span>莫名地注释掉了，取掉注释后，再重新在浏览器地址栏访问css文件，可以看到css文件内容，然后重新访问首页，一切正常了。</div><br /><br /><img src ="http://www.cnitblog.com/houcy/aggbug/86862.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2012-12-23 00:16 <a href="http://www.cnitblog.com/houcy/archive/2012/12/23/86862.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下high CPU分析心得</title><link>http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Wed, 28 Nov 2012 05:21:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/86801.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/86801.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/86801.html</trackback:ping><description><![CDATA[<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:TrackMoves/>
  <w:TrackFormatting/>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-US</w:LidThemeOther>
  <w:LidThemeAsian>ZH-CN</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:DontVertAlignCellWithSp/>
   <w:DontBreakConstrainedForcedTables/>
   <w:DontVertAlignInTxbx/>
   <w:Word11KerningPairs/>
   <w:CachedColBalance/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math" />
   <m:brkBin m:val="before" />
   <m:brkBinSub m:val="&#45;-" />
   <m:smallFrac m:val="off" />
   <m:dispDef/>
   <m:lMargin m:val="0" />
   <m:rMargin m:val="0" />
   <m:defJc m:val="centerGroup" />
   <m:wrapIndent m:val="1440" />
   <m:intLim m:val="subSup" />
   <m:naryLim m:val="undOvr" />
  </m:mathPr></w:WordDocument>
</xml><![endif]--><br />1.用top命令查看哪个进程占用CPU高<br />gateway网关进程14094占用CPU高达891%，这个数值是进程内各个线程占用CPU的累加值。<br /><br />
<div><span style="font-family: Lucida Console">&nbsp; PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND&nbsp;&nbsp;&nbsp;&nbsp; <br /></span><span style="font-family: Lucida Console; color: red">14094 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 15&nbsp;&nbsp; 0&nbsp; 315m&nbsp; 10m 7308 S </span><span style="font-family: Lucida Console; color: red">891%</span><span style="font-family: Lucida Console; color: red">&nbsp; 2.2&nbsp;&nbsp; 1:49.01 gateway</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br /><span style="font-family: Lucida Console">20642 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17&nbsp;&nbsp; 0 17784 4148 2220 S&nbsp; 0.5&nbsp; 0.8&nbsp;&nbsp; 2:39.96 microdasys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><br /><span style="font-family: Lucida Console">&nbsp;1679 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18&nbsp;&nbsp; 0 10984 1856 1556 R&nbsp; 0.3&nbsp; 0.4&nbsp;&nbsp; 0:22.21 sshd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><br /><span style="font-family: Lucida Console">22563 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18&nbsp;&nbsp; 0&nbsp; 2424 1060&nbsp; 800 R&nbsp; 0.3&nbsp; 0.2&nbsp;&nbsp; 0:00.03 top&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><br /><span style="font-family: Lucida Console">&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18&nbsp;&nbsp; 0&nbsp; 2156&nbsp; 492&nbsp; 460 S&nbsp; 0.0&nbsp; 0.1&nbsp;&nbsp; 0:01.59 init</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><br />2.用top -H -p pid命令查看进程内各个线程占用的CPU百分比<br /><br />#top -H -p 14094<br />top中可以看到有107个线程，但是下面9个线程占用CPU很高，下面以线程14086为主，分析其为何high CPU<br /><br />
<div>
<p><span style="font-family: Lucida Console">&nbsp; PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><strong><span style="font-family: Lucida Console; color: #003300">14086</span></strong><span style="font-family: Lucida Console"> root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp; <span style="font-family: Lucida Console; color: red">101</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 21:35.46 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14087 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0 &nbsp;922m 914m 538m R&nbsp; <span style="font-family: Lucida Console; color: red">101</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 10:50.22 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14081 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m S&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">99</span></span><span style="font-family: Lucida Console"> 10.0&nbsp;&nbsp; 8:57.36 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14082 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">99</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 11:51.92 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14089 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">99</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 21:21.77 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14092 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">99</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 19:55.47 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14094 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">99</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 21:02.21 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family: Lucida Console">14083 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp; 922m 914m 538m R&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">97</span></span><span style="font-family: Lucida Console"> 10.0&nbsp; 21:32.39 gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p><span style="font-family: Lucida Console; font-size: 11pt">14088&nbsp; root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp; 0&nbsp;&nbsp; 922m 914m&nbsp; 538m R&nbsp;&nbsp;&nbsp; <span style="font-family: Lucida Console; color: red">97</span></span><span style="font-family: Lucida Console; font-size: 11pt"> 10.0&nbsp;&nbsp; 11:23.12&nbsp; gateway </span></div><br />3.使用gstack命令查看进程中各线程的函数调用栈<br />#gstack 14094 &gt; gstack.log<br />在gstack.log中查找线程ID14086，由于函数栈会暴露函数细节，因此只显示了两个函数桢，线程ID14086对应线程号是37<br /><br />
<div>Thread <span style="color: #800000">37</span> (Thread 0x4696ab90 (LWP <span style="color: #800000">14086</span>)):<br />#0&nbsp; 0x40000410 in __kernel_vsyscall ()<br />#1&nbsp; 0x40241f33 in poll () from /lib/i686/nosegneg/libc.so.6</div><br />4.使用gcore命令转存进程映像及内存上下文<br /><br />#gcore 14094<br />该命令生成core文件core.14094<br /><br /><br />5。用strace命令查看系统调用和花费的时间<br />#strace -T -r -c -p 14094<br /><br />-c参数显示统计信息，去掉此参数可以查看每个系统调用话费的时间及返回值。<br /><br />
<div>
<p><span style="font-family: 'Courier New'; color: black">% time&nbsp;&nbsp;&nbsp;&nbsp; seconds&nbsp; usecs/call&nbsp;&nbsp;&nbsp;&nbsp; calls&nbsp;&nbsp;&nbsp; errors &nbsp;&nbsp;&nbsp; </span>&nbsp;&nbsp; <span style="font-family: 'Courier New'; color: black">syscall</span></p>
<p><span style="font-family: 'Courier New'; color: black">------ ----------- ----------- --------- --------- ----------------------------</span></p>
<p><span style="font-family: 'Courier New'; color: #c00000">99.99&nbsp;&nbsp; 22.683879&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3385&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6702&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>&nbsp;&nbsp; &nbsp;&nbsp; <span style="font-family: 'Courier New'; color: #c00000">poll</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.001132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6702&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>&nbsp;&nbsp; &nbsp;&nbsp; <span style="font-family: 'Courier New'; color: black">gettimeofday</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000127&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 208&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 208 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; accept</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 14&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; time</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stat64</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; clock_gettime</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; send</span></p>
<p><span style="font-family: 'Courier New'; color: black">&nbsp; 0.00&nbsp;&nbsp;&nbsp; 0.000000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; recvfrom</span></p>
<p><span style="font-family: 'Courier New'; color: black">------ ----------- ----------- --------- --------- ------------------------------</span></p>
<p><span style="font-family: 'Courier New'; color: black">100.00&nbsp;&nbsp; 22.685160&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13652&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 218 total</span></p></div><br /><br /><br />
<div>6.用gdb调试core文件，并线程切换到37号线程<br />gcore和实际的core dump时产生的core文件几乎一样，只是不能用gdb进行某些动态调试<br /><br />
<div>(gdb) gdb gateway core.14094 <br />(gdb) thread 37<br />[Switching to thread 37 (Thread 0x4696ab90 (LWP 14086))]#0&nbsp; 0x40000410 in __kernel_vsyscall ()<br />(gdb) where<br />#0&nbsp; 0x40000410 in __kernel_vsyscall ()<br />#1&nbsp; 0x40241f33 in poll () from /lib/i686/nosegneg/libc.so.6</div><br />可以根据详细的函数栈进行gdb调试，打印一些变量值，并结合源代码分析为何会poll调用占用很高的CPU。<br />因为代码涉及到公司产权，顾不在此做详细分析，需要明白的是分析的流程和使用的命令。<br /><br />流程为：进程ID-&gt;线程ID-&gt;线程函数调用栈-&gt;函数耗时和调用统计-&gt;源代码分析</div><img src ="http://www.cnitblog.com/houcy/aggbug/86801.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2012-11-28 13:21 <a href="http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++好网站及其他网站收录</title><link>http://www.cnitblog.com/houcy/archive/2011/09/21/75571.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Wed, 21 Sep 2011 02:43:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2011/09/21/75571.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/75571.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2011/09/21/75571.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/75571.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/75571.html</trackback:ping><description><![CDATA[<p align="left"><strong>** C++ 灵魂人物(Spirit)</strong></p>
<p align="left">Bjarne Stroustrup&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<a href="http://www.research.att.com/~bs/" target="_blank">http://www.research.att.com/~bs/</a></p>
<p align="left">Stanley B. Lippman&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://people.we.mediaone.net/stanlipp/index.html" target="_blank">http://people.we.mediaone.net/stanlipp/index.html</a></p>
<p align="left">Scott Meyers&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://www.aristeia.com/" target="_blank">http://www.aristeia.com/</a></p>
<p align="left">David Musser&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://www.cs.rpi.edu/~musser/" target="_blank">http://www.cs.rpi.edu/~musser/</a></p>
<p align="left">Bruce Eckel&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<a href="http://www.cs.rpi.edu/~musser/" target="_blank">http://www.bruceeckel.com</a></p>
<p align="left">Nicolai M. Josuttis&nbsp; &nbsp;<a href="http://www.chinaitpower.com/www.josuttis.com/" target="_blank">&nbsp;[url]http://www.josuttis.com/</a>[/url]</p>
<p align="left">Herb Sutter&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://www.gotw.ca/" target="_blank">http://www.gotw.ca/</a></p>
<strong>** C++ 深度探索(Inside)</strong><br />
<strong>C++ 编译器免费下载或试用</strong><br />
Borland C++ 5.5&nbsp;http://www.borland.com/bcppbuilder/freecompiler/cppc55steps.html<br />
cygwin&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;http://sources.redhat.com/cygwin/<br />
KAI C++&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;http://www.kai.com/<br />
GNU C++&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;http://gcc.gnu.org/<br />
C++ 相关资源(很好的C++英文程序网站)G++ FAQ&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;http://www.faqs.org/faqs/g++-FAQ/<br />
ISO IEC JTC1/SC22/WG21 - C++&nbsp;&nbsp;http://anubis.dkuug.dk/jtc1/sc22/wg21/<br />
open source project&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;http://www.sourceforge.net&nbsp;<br />
C++ Boost&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;http://www.boost.org/&nbsp;<br />
中文C++技术网&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://flagon.net9.org/" target="_blank">http://flagon.net9.org/&nbsp;</a><br />
<br />
<strong>泛型编程 GP / STL</strong><br />
STLport&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;http://www.stlport.org/&nbsp;<br />
Dinkum C++ Library&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;http://www.dinkumware.com/<br />
SGI STL&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;http://www.sgi.com/tech/stl/&nbsp;<br />
RougeWave Standard C++ Library&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;http: //www.ccd.bnl.gov/bcf/cluster/pgi/pgC++_lib/stdlib.htm<br />
A collection of STL documentation&nbsp; &nbsp;http://www.ge.infn.it/geant4/training/stl.html<br />
<strong>期刊</strong>&nbsp;<br />
Dr. Dobb's Journal&nbsp; &nbsp;&nbsp;http://www.ddj.com/<br />
C/C++ Users Journal&nbsp; &nbsp;&nbsp;http://www.cuj.com/<br />
<br />
<strong>** C++ 网络导向(Net)</strong>&nbsp;<br />
网络编程(programsalon)&nbsp;http://www.programsalon.com/default.asp&nbsp;(附大量网络程序代码)<br />
Linux&nbsp;http://www.linuxbyte.net<br />
永远的UNix 编程&nbsp;http://www.fanqiang.com/<br />
<br />
<strong>** C++ 广度延伸(Explore)</strong><br />
<strong>Patterns</strong>&nbsp;<br />
Pattern Depot&nbsp; &nbsp;http://www.patterndepot.com<br />
Huston Design Patterns&nbsp;&nbsp;http://rampages.onramp.net/~huston/dp/patterns.html<br />
软件工程专家网 [url=file:///F:/server?%27))window.location=%27<a href="http://www.21cmm.com/%27" target="_blank">http://www.21cmm.com/%27</a>]http://www.21cmm.com[/url]&nbsp;***&nbsp;<br />
系统分析员之窗 [url=file:///F:/server?%27))window.location=%27<a href="http://www.sawin.com.cn/%27" target="_blank">http://www.sawin.com.cn/%27</a>]http://www.sawin.com.cn/[/url]&nbsp;&nbsp;**&nbsp;<br />
工程技术资料 [url=file:///F:/server?%27))window.location=%27<a href="http://person.zj.cninfo.net/~yhaiyan/index.htm%27" target="_blank">http://person.zj.cninfo.net/%7Eyhaiyan/index.htm%27</a>]http://person.zj.cninfo.net/~yhaiyan/index.html[/url]**<br />
<strong>UML</strong>&nbsp;UML Resource Page&nbsp; &nbsp;<a href="http://www.omg.org/technology/uml" target="_blank">http://www.omg.org/technology/uml/&nbsp;</a><br />
UML 播种机&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<a href="http://www.umlchina.com/" target="_blank">http://www.umlchina.com</a><br />
<strong>其他技术连结</strong>&nbsp;&nbsp;AT&amp;T Labs Research - Software Tools&nbsp; &nbsp;<a href="http://www.research.att.com/sw/tools/" target="_blank">http://www.research.att.com/sw/tools/</a><br />
MSDN&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://www.chinaitpower.com/msdn.microsoft.com" target="_blank">&nbsp;[url]http://msdn.microsoft.com</a>[/url]&nbsp;toGet 软件资料库 [url=file:///F:/toget.pchome.com.tw/intro/network_homepage/network_homepage_effect/20000107_5273.html]toget.pchome.com.tw/intro/network_homepage/network_homepage_effect/20000107_5273.html[/url]<br />
<br />
&nbsp;安全网站<br />
http://www.securityfocus.com<br />
http://www.20cn.net 20cn网络安全小组&nbsp;<br />
http://www.cnns.net/frankie 早期黑客网站(<a href="http://www.cnns.net/frankie/hack/hac1.htm" target="_blank">http://www.cnns.net/frankie/hack/hac1.htm</a>)<br />
http://www.chinawebfan.com/abc/hlc/ 中华黑盟&nbsp;http://www.xfocus.net 不错的安全站点，有一些编程知识<br />
http://www.peckerland.com 有很多网络高手的网站&nbsp;http://www.netxeyes.com 小榕软件&nbsp;++<br />
http://fetag.dhs.org/, coolfire 大师级的黑客个人网站&nbsp;中联绿盟--绿色兵团的商业网站<a href="http://www.nsfocus.com/" target="_blank">http://www.nsfocus.com</a><br />
绿色兵团--国内很老的黑客站<br />
http://www.vertarmy.com&nbsp;红客联盟--近来新崛起势力很旺的黑客网站<br />
http://www.cnhonker.org<br />
白菜乐园--著名的国内解密加密网站<br />
http://secrecy.ayinfo.ha.con&nbsp;中国鹰派--鹰派主站<br />
http://www.chinawill.com<br />
http://www.is01.com&nbsp;http://www.huzhou.zj.cn/~yuange/　　袁哥的技术网<br />
http://www.safefan.com/index1.htm　傲气雄鹰&nbsp;网络技术--外国网站<br />
http://www.hack.co.za&nbsp;<br />
<br />
网络安全评估中心<br />
http://www.msecure.org&nbsp;<strong>其他(计算机)</strong>&nbsp;<br />
http://pande.363.net/ 程序。英语 不少介绍程序员故事及风格的文章<br />
http://www.lili.cc/ 2000年最佳女性网站&nbsp;&nbsp;http://www.xxinfo.net 湘西数码港(<a href="http://www.416000.com/" target="_blank">www.416000.com</a>) http://asm.yeah.net/（<a href="http://bigluo.tz163.net/" target="_blank">http://bigluo.tz163.net</a>） 罗云彬编程乐园　好的汇编网站<br />
http://www.zoudan.com 邹丹 http://www.drbob42.com经典个人Notes和Delphi，Linux结合网站<br />
http://www.codelphi.com (codelphi)中国开发在线，不错的中文delphi网站,用户<br />
http://sunsite.icm.edu.pl delphi经典网站 http://vcl.vclxx.org/ delphi 深度历险　 风魂--以游戏编程为主<br />
http://member.netease.com/~cloudwu&nbsp;<br />
Oracle 技术网，大量的oracle知识　<br />
http://www.oradb.net Lotus 莲花中国官方网站<br />
http://www.lotus.com.cn<br />
很好的英文notes网站，在iris sandbox有不少专家例子<br />
http://www.notes.net 由专家和教授建立的英文网站，在download中心有不少好例<br />
http://www.notes411.com<br />
个人很好的英文网站，有个人产品例子及好贴子<br />
http://www.notesdesign.com 电脑爱好者杂志网<br />
http://www.cfan.cn.net<br />
大众软件杂志网<br />
http://www.popsoft.com.cn 互联网周刊杂志网<br />
http://www.ciweekly.com<br />
问专家　--大量各种编程问题，不明白之处专家会及时答复<br />
http://www.china-askpro.com 电脑教育报杂志网<br />
http://www.cce.com.cn&nbsp;<br />
&nbsp;<br />
<strong>其他(杂项)</strong>&nbsp;&nbsp;网上地图<br />
http://www.go2tomap.com 联合早报&nbsp;<a href="http://www.zaobao.com/" target="_blank">http://www.zaobao.com</a><br />
中国科技网<br />
http://www.cnc.ac.cn/net 中国科普网，大量的科普知识<br />
http://www.kepu.com.cn<br />
冠群金辰，杀毒网站<br />
http://sc.kill.com.cn 渔人码头,九八年最佳清新网站<br />
http://rabbitty.yeah.net<br />
福瑞网免费空间，大量的免费信息<br />
http://www.254free.net http://www.softdo.com<br />
www.rongshu.com 榕树下<br />
http://www.sxsoft.com (sxsoft1004)项目交易平台，有大量交易软件项目、开发&nbsp;<br />
中国安全信息论詓--全国最大的漏洞库<br />
http://www.chinafirst.org<br />
<br />
<br />
@import url(http://www.cnitblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);<img src ="http://www.cnitblog.com/houcy/aggbug/75571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2011-09-21 10:43 <a href="http://www.cnitblog.com/houcy/archive/2011/09/21/75571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>openBIOS -- coreboot</title><link>http://www.cnitblog.com/houcy/archive/2011/03/10/73055.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 10 Mar 2011 07:40:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2011/03/10/73055.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/73055.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2011/03/10/73055.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/73055.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/73055.html</trackback:ping><description><![CDATA[-------------------------------------------------------------------------------<br>coreboot README<br>-------------------------------------------------------------------------------<br><br>coreboot is a Free Software project aimed at replacing the proprietary<br>BIOS you can find in most of today's computers.<br><br>It performs just a little bit of hardware initialization and then executes<br>one of many possible payloads, e.g. a Linux kernel or a bootloader.<br><br><br>Payloads<br>--------<br><br>After the basic initialization of the hardware has been performed, any<br>desired "payload" can be started by coreboot.<br><br>See http://www.coreboot.org/Payloads for a list of supported payloads.<br><br><br>Supported Hardware<br>------------------<br><br>coreboot supports a wide range of chipsets, devices, and mainboards.<br><br>For details please consult:<br><br>&nbsp;* http://www.coreboot.org/Supported_Motherboards<br>&nbsp;* http://www.coreboot.org/Supported_Chipsets_and_Devices<br><br><br>Build Requirements<br>------------------<br><br>&nbsp;* gcc / g++<br>&nbsp;* make<br><br>Optional:<br><br>&nbsp;* doxygen (for generating/viewing documentation)<br>&nbsp;* iasl (for targets with ACPI support)<br>&nbsp;* gdb (for better debugging facilities on some targets)<br>&nbsp;* ncurses (for 'make menuconfig')<br>&nbsp;* flex and bison (for regenerating parsers)<br><br><br>Building coreboot<br>-----------------<br><br>Please consult http://www.coreboot.org/Build_HOWTO for details.<br><br><br>Testing coreboot Without Modifying Your Hardware<br>------------------------------------------------<br><br>If you want to test coreboot without any risks before you really decide<br>to use it on your hardware, you can use the QEMU system emulator to run<br>coreboot virtually in QEMU.<br><br>Please see http://www.coreboot.org/QEMU for details.<br><br><br>Website and Mailing List<br>------------------------<br><br>Further details on the project, a FAQ, many HOWTOs, news, development<br>guidelines and more can be found on the coreboot website:<br><br>&nbsp; http://www.coreboot.org<br><br>You can contact us directly on the coreboot mailing list:<br><br>&nbsp; http://www.coreboot.org/Mailinglist<br><br><br>Copyright and License<br>---------------------<br><br>The copyright on coreboot is owned by quite a large number of individual<br>developers and companies. Please check the individual source files for details.<br><br>coreboot is licensed under the terms of the GNU General Public License (GPL).<br>Some files are licensed under the "GPL (version 2, or any later version)",<br>and some files are licensed under the "GPL, version 2". For some parts, which<br>were derived from other projects, other (GPL-compatible) licenses may apply.<br>Please check the individual source files for details.<br><br>This makes the resulting coreboot images licensed under the GPL, version 2.<br><br><img src ="http://www.cnitblog.com/houcy/aggbug/73055.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2011-03-10 15:40 <a href="http://www.cnitblog.com/houcy/archive/2011/03/10/73055.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mp3tag v2.48 - the universal Tag Editor and more ...</title><link>http://www.cnitblog.com/houcy/archive/2011/02/01/72752.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Tue, 01 Feb 2011 02:33:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2011/02/01/72752.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/72752.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2011/02/01/72752.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/72752.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/72752.html</trackback:ping><description><![CDATA[<p>Mp3tag is a powerful and yet easy-to-use tool to edit metadata of common audio formats where it supports ID3v1, ID3v2.3, ID3v2.4, iTunes MP4, WMA, Vorbis Comments and APE Tags.</p>
<p>It can rename files based on the tag information, replace characters or words in tags and filenames, import/export tag information, create playlists and <a href="http://www.mp3tag.de/en/index.html#features"><u><font color=#0066cc>more</font></u></a>.</p>
<p>Mp3tag supports online database lookups from, e.g., Amazon, discogs, or freedb, allowing you to automatically gather proper tags and cover art for your music library.</p>
&nbsp;<br>
<table>
    <tbody>
        <tr>
            <td><a title=Screenshots href="http://www.mp3tag.de/en/screenshots.html"><img class=preview alt=Screenshots src="http://www.mp3tag.de/en/images/tmb_main.png"></a> </td>
            <td><span class=hilight>Mp3tag supports the following audio formats:</span><br>
            <ul class=bulletlist>
                <li><a href="http://www.audiocoding.com/"><u><font color=#0066cc>Advanced Audio Coding (aac)</font></u></a></li>
                <li><a href="http://flac.sourceforge.net/"><u><font color=#0066cc>Free Lossless Audio Codec (flac)</font></u></a></li>
                <li><a href="http://www.monkeysaudio.com/"><u><font color=#0066cc>Monkey's Audio (ape)</font></u></a></li>
                <li><a href="http://www.mp3-tech.org/"><u><font color=#0066cc>Mpeg Layer 3 (mp3)</font></u></a></li>
                <li><a href="http://www.audiocoding.com/"><u><font color=#0066cc>MPEG-4 (mp4 / m4a / m4b / iTunes compatible)</font></u></a></li>
                <li><a href="http://www.musepack.net/"><u><font color=#0066cc>Musepack (mpc)</font></u></a></li>
                <li><a href="http://www.vorbis.com/"><u><font color=#0066cc>Ogg Vorbis (ogg)</font></u></a></li>
                <li><a href="http://losslessaudiocompression.com/"><u><font color=#0066cc>OptimFROG (ofr)</font></u></a></li>
                <li><a href="http://losslessaudiocompression.com/"><u><font color=#0066cc>OptimFROG DualStream (ofs)</font></u></a></li>
                <li><a href="http://www.speex.org/"><u><font color=#0066cc>Speex (spx)</font></u></a></li>
                <li><a href="http://www.thbeck.de/Tak/Tak.html"><u><font color=#0066cc>Tom's Audio Kompressor (tak)</font></u></a></li>
                <li><a href="http://tta.corecodec.org/"><u><font color=#0066cc>True Audio (tta)</font></u></a></li>
                <li><a href="http://www.windowsmedia.com/"><u><font color=#0066cc>Windows Media Audio (wma)</font></u></a></li>
                <li><a href="http://www.wavpack.com/"><u><font color=#0066cc>WavPack (wv)</font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<br>download from here:<br><a href="http://download.mp3tag.de/mp3tagv248setup.exe">http://download.mp3tag.de/mp3tagv248setup.exe</a>
<img src ="http://www.cnitblog.com/houcy/aggbug/72752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2011-02-01 10:33 <a href="http://www.cnitblog.com/houcy/archive/2011/02/01/72752.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用gawk写的日志分析器</title><link>http://www.cnitblog.com/houcy/archive/2010/12/09/72133.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 09 Dec 2010 07:15:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/12/09/72133.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/72133.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/12/09/72133.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/72133.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/72133.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 两年前用于工作需要我用gawk写的解析系统日志的代码，贴出来留着方便回忆gawk语法。&nbsp;&nbsp;1#!/usr/bin/gawk&nbsp;&nbsp;2&nbsp;&nbsp;3BEGIN&nbsp;{&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;RS="+++"&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;ast=0;&...&nbsp;&nbsp;<a href='http://www.cnitblog.com/houcy/archive/2010/12/09/72133.html'>阅读全文</a><img src ="http://www.cnitblog.com/houcy/aggbug/72133.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-12-09 15:15 <a href="http://www.cnitblog.com/houcy/archive/2010/12/09/72133.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我的.vimrc配置文件</title><link>http://www.cnitblog.com/houcy/archive/2010/11/18/71439.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 18 Nov 2010 07:15:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/11/18/71439.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/71439.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/11/18/71439.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/71439.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/71439.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 算是一个备份吧，自我感觉.vimrc配置的还不错&nbsp;&nbsp;1set&nbsp;helplang=cn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&nbsp;2set&nbsp;encoding=utf-8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n...&nbsp;&nbsp;<a href='http://www.cnitblog.com/houcy/archive/2010/11/18/71439.html'>阅读全文</a><img src ="http://www.cnitblog.com/houcy/aggbug/71439.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-11-18 15:15 <a href="http://www.cnitblog.com/houcy/archive/2010/11/18/71439.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>打造Linux下的IDE调试开发环境 clewn + gdb + gvim</title><link>http://www.cnitblog.com/houcy/archive/2010/11/18/71438.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 18 Nov 2010 07:09:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/11/18/71438.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/71438.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/11/18/71438.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/71438.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/71438.html</trackback:ping><description><![CDATA[<p>在Linux还没有很方便的IDE的调试开发环境，不过使用clewn+gdb+gvim可以打造一款不错的IDE，由于vim有很多插件可以使用，所以很方便代码跳转和索引查找。<br><br>本文简单记录本人安装配置过程，clewn必须和7.0以上版本的gvim一起使用才行。</p>
<p>【Install】<br>cp ~houcy/clewn.tar.gz&nbsp; to_you_dir&nbsp; 解压缩，然后把clewn的目录导入到Path里<br>cp /home/houcy/.vim/plugin/clewn.vim&nbsp; ~yours/.vim/plugin/ <br>cp /home/houcy/.vim/doc/clewn.txt&nbsp; ~yours/.vim/doc/ <br>cp /home/houcy/.vim/macros/clewn_mappings.vim&nbsp; ~yours/.vim/macros/ <br>cp /home/houcy/.vim/syntax/gdbvar.vim&nbsp; ~your/.vim/syntax/<br>&nbsp;<br>【Usage】<br>1. clewn&nbsp; -va&nbsp; main.cc 该命令会自动在gvim中打开main.cc，同时运行gdb<br>2. 在已经运行的gdb中输入命令&nbsp; file&nbsp;&nbsp;main<br>3. 然后即可在gvim里按键调试程序了，参考下面的key mapping:<br>&nbsp;<br>【运行示例】<br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 93.97%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 621px; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">bj2amdlnx16</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;clewn&nbsp;&nbsp; </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">va&nbsp;&nbsp;&nbsp; main.cc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><img src="http://www.cnitblog.com/Images/dot.gif"><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><img src="http://www.cnitblog.com/Images/dot.gif">&nbsp;Clewn&nbsp;</span><span style="COLOR: #000000">1.14</span><span style="COLOR: #000000">&nbsp;running&nbsp;GDB&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;level&nbsp;</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">&nbsp;mode<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><img src="http://www.cnitblog.com/Images/dot.gif"><br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>GNU&nbsp;gdb&nbsp;Red&nbsp;Hat&nbsp;Linux&nbsp;(</span><span style="COLOR: #000000">6.3</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">0.0</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1.159</span><span style="COLOR: #000000">.el4rh)<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Copyright&nbsp;</span><span style="COLOR: #000000">2004</span><span style="COLOR: #000000">&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;Inc.<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>GDB&nbsp;</span><span style="COLOR: #0000ff">is</span><span style="COLOR: #000000">&nbsp;free&nbsp;software,&nbsp;covered&nbsp;by&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License,&nbsp;</span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000">&nbsp;you&nbsp;are<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>welcome&nbsp;to&nbsp;change&nbsp;it&nbsp;</span><span style="COLOR: #0000ff">and</span><span style="COLOR: #000000">/</span><span style="COLOR: #0000ff">or</span><span style="COLOR: #000000">&nbsp;distribute&nbsp;copies&nbsp;of&nbsp;it&nbsp;under&nbsp;certain&nbsp;conditions.<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Type&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">show&nbsp;copying</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;to&nbsp;see&nbsp;the&nbsp;conditions.<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>There&nbsp;</span><span style="COLOR: #0000ff">is</span><span style="COLOR: #000000">&nbsp;absolutely&nbsp;no&nbsp;warranty&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;GDB.&nbsp;&nbsp;Type&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">show&nbsp;warranty</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;details.<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>This&nbsp;GDB&nbsp;was&nbsp;configured&nbsp;as&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">x86_64-redhat-linux-gnu</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">.<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>`run</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&nbsp;commands&nbsp;do&nbsp;input&nbsp;and&nbsp;output&nbsp;on&nbsp;the&nbsp;terminal&nbsp;/dev/pts/32</span><span style="COLOR: #800000"><br></span><span style="COLOR: #008080">14</span><span style="COLOR: #800000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>NetBeans&nbsp;listens&nbsp;on&nbsp;localhost:</span><span style="COLOR: #000000">3219&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #使用NetBeans通信，在本地开个监听端口</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>NetBeans&nbsp;connected&nbsp;to&nbsp;</span><span style="COLOR: #000000">127.0</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">0.1</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">46403</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;file&nbsp;</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">vobs</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre_dev</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">tools.lnx86</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">bin</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">32bit</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Reading&nbsp;symbols&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">vobs</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre_dev</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">tools.lnx86</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">bin</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">32bit</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre<img src="http://www.cnitblog.com/Images/dot.gif">done.<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Using&nbsp;host&nbsp;libthread_db&nbsp;library&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">/lib64/tls/libthread_db.so.1</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">.<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;b&nbsp;main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;#此处表示正忙，因为clewn需要通过netbean和gdb进程间通信<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>GDB&nbsp;busy:&nbsp;command&nbsp;discarded,&nbsp;please&nbsp;retry<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;b&nbsp;main<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Breakpoint&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x8766724</span><span style="COLOR: #000000">:&nbsp;file&nbsp;main.cc,&nbsp;line&nbsp;</span><span style="COLOR: #000000">48</span><span style="COLOR: #000000">.<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;r<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Starting&nbsp;program:&nbsp;</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">vobs</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre_dev</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">tools.lnx86</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">bin</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">32bit</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">spectre<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Reading&nbsp;symbols&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;shared&nbsp;object&nbsp;read&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;target&nbsp;memory<img src="http://www.cnitblog.com/Images/dot.gif">done.<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Loaded&nbsp;system&nbsp;supplied&nbsp;DSO&nbsp;at&nbsp;</span><span style="COLOR: #000000">0xffffe000</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>[Thread&nbsp;debugging&nbsp;using&nbsp;libthread_db&nbsp;enabled]<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>[New&nbsp;Thread&nbsp;</span><span style="COLOR: #000000">4008068800</span><span style="COLOR: #000000">&nbsp;(LWP&nbsp;</span><span style="COLOR: #000000">31793</span><span style="COLOR: #000000">)]<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>[Switching&nbsp;to&nbsp;Thread&nbsp;</span><span style="COLOR: #000000">4008068800</span><span style="COLOR: #000000">&nbsp;(LWP&nbsp;</span><span style="COLOR: #000000">31793</span><span style="COLOR: #000000">)]<br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Breakpoint&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,&nbsp;main&nbsp;(argc</span><span style="COLOR: #000000">=-</span><span style="COLOR: #000000">14287</span><span style="COLOR: #000000">,&nbsp;argv</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0xffffc854</span><span style="COLOR: #000000">)&nbsp;at&nbsp;main.cc:</span><span style="COLOR: #000000">48</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)<br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<p>&nbsp;<br>【效果图】<br><img height=761 alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/clewn.JPG" width=792 border=0></p>
<img src ="http://www.cnitblog.com/houcy/aggbug/71438.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-11-18 15:09 <a href="http://www.cnitblog.com/houcy/archive/2010/11/18/71438.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>expect Ｑ＆Ａ</title><link>http://www.cnitblog.com/houcy/archive/2010/04/13/65254.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Tue, 13 Apr 2010 08:42:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/04/13/65254.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/65254.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/04/13/65254.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/65254.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/65254.html</trackback:ping><description><![CDATA[<strong>１.　Can Expect automatically generate a script from watching a session?</strong>
<p>
<pre>From: libes (Don Libes)
To: pete@willow24.cray.com
Subject: Expect
Date: Fri, 12 Oct 90 17:16:47 EDT
&gt;I like "Expect" and am thinking of using it to help automate the
&gt;testing of interactive programs.  It would be useful if Expect had a
&gt;"watch me" mode, where it "looks over the shoulder" of the user and
&gt;records his keystrokes for later use in an Expect script.
&gt;
&gt;(Red Ryder and other Macintosh telecommunications packages offer this
&gt;sort of thing.  You log onto Compuserve once in "watch me" mode, and
&gt;RR keeps track of the keystrokes/prompts.  When you're done you have a
&gt;script that can be used to log onto Compuserve automatically.)
&gt;
&gt;Before I look into adding a "watch me" feature, I thought I should
&gt;ask: has this been done already?
&gt;
&gt;I'll say again that I like the tool a lot--nice work!  There are other
&gt;people here using it for things like the testing of ksh, which
&gt;responds differently to signals when not used interactively.
&gt;
&gt;-- Pete
</pre>
<p>The autoexpect script in Expect's example directory does what you want.</p>
<p><a href="http://www.nist.gov/msidstaff/libes"><u><font color=#800080>Don</font></u></a></p>
<br>２.<strong>How do I send control characters or function keys?</strong>
<p>
<p>Sending control characters is easy: just write a send command and enter the control character you want to send.</p>
<p>I like to enter most control characters literally - since the resulting script is more readable. However, your editor has to allow this. For example, suppose you want to send a Control-A. Conventionally, most editors display this as ^A, but you can't just enter ^ and A. (This will just send those two characters.) Most editors have some simple quoting mechanism that lets you enter the next character literally. For example, using emacs, I can enter ^Q^A and that will add the single character ^A.</p>
<p>Alternatively, Tcl provides a way of encoding using octal or hex. The octal encoding mechanism is less error-prone than hex so I'll demonstrate using octal. For example, since ^A has the octal value 1 in ASCII, to send a ^A:</p>
<pre>    send "\01"
</pre>
<p>To send function keys, you need to know one more thing - what characters are assigned to a function key. Function keys are generally specific to the type of terminal (or terminal emulator) you are using, so it's easiest to just try pressing the function key and see what you get. In order to get the clearest picture, I use the od program to help me. Here are the steps I use:</p>
<ol>
    <li>start od with the -c option
    <li>press the function key
    <li>press the return key
    <li>press ^D </li>
</ol>
<p>Here's what it looks like when I do that to find out what my F1 key generates:</p>
<pre>    % od -c
^[[11~
0000000 033   [   1   1   ~  \n
0000006
%</pre>
<p>The string between the 0000000 and \n is what we want. You can translate that into a send command like this one:</p>
<pre>    send "\033\[11~"
</pre>
<p>Notice that the 033 was an octal specification already so I put a backslash in front of it to tell Tcl to treat it that way. I also put a backslash in front of the [ to prevent Tcl from trying to execute the next thing as a command.</p>
<p>One complication: characters may massaged (stolen or replaced with other characters) by the terminal driver. For example, in the example above, all the characters produced by the function key were sent to od, but the return character I pressed afterward was translated to a newline - which showed up as in the output of od). Unfortunately, there is no trivial way of turning off all such processing, but you can get rid of the usual offenders by executing the command:</p>
<pre>    stty -isig -icanon -exten -ixon -ixoff
</pre>
<p>This will take care of most driver translations - except for return to newline which you probably don't want to mess with. Since ^D will stop working, you'll need to enter enough characters to get od to finish a line. Enter at least 15 more characters and press return to see some output from od.</p>
<p>Most systems support "stty raw" as a shortcut for the stty command above however not all do. In fact, some systems may not support all the options above. You may have to do some experimentation. Also note that some shells automatically undo any stty command that they "don't like". For example, the Z-shell (zsh) requires "ttyctl -u" before doing a stty like the ones above.</p>
<p>Hopefully, this should answer most of the questions. If you have further questions, please check the book. It has lots of examples of common literal, octal and hex sequences, and using these with send. Plus, it also talks about more sophisticated issues such as using function keys with termcap/terminfo.</p>
<p><a href="http://www.nist.gov/msidstaff/libes"><u><font color=#800080>Don</font></u></a></p>
<br>摘自：<br><a href="http://expect.nist.gov/FAQ.html#q23">http://expect.nist.gov/FAQ.html#q23</a><br><br><br>
<img src ="http://www.cnitblog.com/houcy/aggbug/65254.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-04-13 16:42 <a href="http://www.cnitblog.com/houcy/archive/2010/04/13/65254.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>主流计算机语言家谱</title><link>http://www.cnitblog.com/houcy/archive/2010/04/09/65163.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Fri, 09 Apr 2010 07:49:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/04/09/65163.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/65163.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/04/09/65163.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/65163.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/65163.html</trackback:ping><description><![CDATA[<p><img height=768 alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/lang.JPG" width=597 border=0></p>
<img src ="http://www.cnitblog.com/houcy/aggbug/65163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-04-09 15:49 <a href="http://www.cnitblog.com/houcy/archive/2010/04/09/65163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用expect调用gdb实现自动调试程序</title><link>http://www.cnitblog.com/houcy/archive/2010/02/02/64102.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Tue, 02 Feb 2010 01:46:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/02/02/64102.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/64102.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/02/02/64102.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/64102.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/64102.html</trackback:ping><description><![CDATA[使用gdb调试程序时可以设置断点停在某一行、某个函数或者某个条件满足时停下。但是有时想匹配到一个任意的字符串时让程序停止。这个功能gdb中无法实现，但是借助expect可以实现自动化调试，设置好断点，然后让expect来捕获模式串，一旦获取到，即停止expect，控制权返回到gdb。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #008000">#</span><span style="COLOR: #008000">!/usr/bin/expect</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">####################################################################</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;File:&nbsp;&nbsp;&nbsp;Automatically&nbsp;debug&nbsp;program&nbsp;by&nbsp;gdb</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;Usage:&nbsp;&nbsp;Specify&nbsp;the&nbsp;expected&nbsp;string</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;Author:&nbsp;houcy</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;Date:&nbsp;&nbsp;&nbsp;2010-01-29</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;Plan:&nbsp;&nbsp;&nbsp;Wrap&nbsp;a&nbsp;GUI&nbsp;window&nbsp;to&nbsp;make&nbsp;it&nbsp;user-friendly</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">&nbsp;&nbsp;Copyrights&nbsp;Reserved</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">11</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#</span><span style="COLOR: #008000">####################################################################</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">12</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;{$argc&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">}&nbsp;{<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;send_user&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Usage:&nbsp;$argv0&nbsp;spectre&nbsp;netlist&nbsp;pattern1&nbsp;pattern2&nbsp;<img src="http://www.cnitblog.com/Images/dot.gif">\r\n</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;exit<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>}<br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>set&nbsp;timeout&nbsp;</span><span style="COLOR: #000000">120</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>set&nbsp;done&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>set&nbsp;num&nbsp;0<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;get&nbsp;command&nbsp;line&nbsp;param</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">23</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">set&nbsp;spectre&nbsp;[lindex&nbsp;$argv&nbsp;0]<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>set&nbsp;netlist&nbsp;[lindex&nbsp;$argv&nbsp;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;set&nbsp;pattern&nbsp;array</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">27</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;{set&nbsp;i&nbsp;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">}&nbsp;{&nbsp;$i</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">$argc&nbsp;}&nbsp;{incr&nbsp;i}&nbsp;{<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;pattern($i)&nbsp;[lindex&nbsp;$argv&nbsp;$i]<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$pattern($i)<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>}<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;start&nbsp;gdb&nbsp;process</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">33</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">spawn&nbsp;gdb&nbsp;$spectre<br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;for&nbsp;expect&nbsp;debug</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">36</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">exp_internal&nbsp;0<br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;set&nbsp;some&nbsp;breakpoints</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">39</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">b&nbsp;tranDoAnalysis\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;run&nbsp;program</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">42</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">run&nbsp;$netlist\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;continue&nbsp;to&nbsp;run</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">45</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">b&nbsp;aiEvaluateEHForSoa\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}&nbsp;<br></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">c\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}&nbsp;<br></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">b&nbsp;assertExpressionResult::evaluateExprs\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}&nbsp;<br></span><span style="COLOR: #008080">48</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">c\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">50</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;watch&nbsp;target&nbsp;string,&nbsp;or&nbsp;else&nbsp;continue</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">51</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;($done)&nbsp;{<br></span><span style="COLOR: #008080">52</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;{&nbsp;set&nbsp;j&nbsp;</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">&nbsp;}&nbsp;{&nbsp;$j</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">$argc&nbsp;}&nbsp;{incr&nbsp;j}&nbsp;{<br></span><span style="COLOR: #008080">53</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">$pattern($j)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send_user&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Got&nbsp;$pattern($j)&nbsp;here!&nbsp;num=$num\r\n</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">;&nbsp;set&nbsp;done&nbsp;0&nbsp;;&nbsp;</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">}<br></span><span style="COLOR: #008080">54</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></span><span style="COLOR: #008080">55</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;{&nbsp;$done&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;0&nbsp;}&nbsp;{&nbsp;</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;}<br></span><span style="COLOR: #008080">56</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect&nbsp;{<br></span><span style="COLOR: #008080">57</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">(gdb)</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;{&nbsp;send&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">c\r</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;;&nbsp;set&nbsp;num&nbsp;[expr&nbsp;$num</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]&nbsp;;&nbsp;send_user&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">num=$num\r\n</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">58</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eof&nbsp;{&nbsp;send_user&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">It's&nbsp;the&nbsp;end!&nbsp;Bye!\r\n</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">59</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout&nbsp;{&nbsp;send_user&nbsp;</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Timeout,&nbsp;please&nbsp;check&nbsp;the&nbsp;reason!\r\n</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">&nbsp;}<br></span><span style="COLOR: #008080">60</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></span><span style="COLOR: #008080">61</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>}<br></span><span style="COLOR: #008080">62</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">63</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">&nbsp;back&nbsp;to&nbsp;gdb&nbsp;control</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">64</span><span style="COLOR: #008000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">interact<br></span><span style="COLOR: #008080">65</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<br>运行程序：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">bj2amdlnx20</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;.</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">gdb.exp&nbsp;spectre&nbsp;netlist&nbsp;sweepValue</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">.e</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">10</span></div>
<br>expect捕获到模式串，返回到gdb中：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">1<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;b&nbsp;assertExpressionResult::evaluateExprs<br>2<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Breakpoint&nbsp;3&nbsp;at&nbsp;0x8b57fe0:&nbsp;file&nbsp;assertInterface.cc,&nbsp;line&nbsp;2174.<br>3<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)&nbsp;c<br>4<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Continuing.<br>5<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br>6<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Breakpoint&nbsp;3,&nbsp;assertExpressionResult::evaluateExprs&nbsp;(sweepValue=1e-10,&nbsp;checklimitSeverity=0,&nbsp;violationDest=4&nbsp;'\004',&nbsp;<br>7<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #ff0000">Got&nbsp;sweepValue=1e-10&nbsp;here!&nbsp;num=0<br></span>8<img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>(gdb)</div>
<img src ="http://www.cnitblog.com/houcy/aggbug/64102.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-02-02 09:46 <a href="http://www.cnitblog.com/houcy/archive/2010/02/02/64102.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于程序算法解决问题的总结</title><link>http://www.cnitblog.com/houcy/archive/2010/01/30/64071.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sat, 30 Jan 2010 10:02:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/01/30/64071.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/64071.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/01/30/64071.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/64071.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/64071.html</trackback:ping><description><![CDATA[<p>用程序算法来解决问题，需要具备什么样的indispensable knowledge呢？ 个人认为以下5点是不可或缺的：<br><br>1. Problem-solving skills.<br>&nbsp;&nbsp; 首先是要有解决问题的技能，就是要有固定成型的解决问题的思考模式，这个很重要，遇到千变万化的问题，采用一套有效的思考模式会事半功倍！究竟是什么样的思考模式比较有效呢，数学大师波利亚的巨著《How to solve it》给出了很好的解决问题的思考模式！对于程序解题来说，可以把波利亚的思考模式具体化，借用一下面向对象里的继承机制，Problem-solving-by-algorithm派生自Polya's-problem-solving-skills. 计算机科学家Steven Skiena在他的典著《The Algorithm Design Manual》中给出了程序算法解题的分析思考模式，非常值得借鉴。<br><br>2. Algorithm Design Skills.<br>&nbsp;&nbsp;&nbsp; 其次是要选择正确的算法策略。算法设计时要区分strategy和tactics。算法设计的策略有贪心、分治、动态规划、启发式、蛮力、穷举。。。，当策略选择正确后，再选择tactics。要很好地理解策略的思想，思想是旗帜，是行动指南！<br>&nbsp;&nbsp; <br>3. Data Structure Knowledge<br>&nbsp;&nbsp; 常见的数据结构有set, array, list, tree, graph, string, stack, heap, queue, priority queue等<br><br>4. Algorithm Knowledge<br>&nbsp;&nbsp; 这里的算法相对于前面的strategy就是tactics，是具体的做法了，如排序算法（快速排序，归并排序，堆排序，基数排序，插入排序等等）、搜索算法（DFS, BFS，A*等等）、字符串模式匹配、排列组合算法、几何算法等等。 这些算法往往是针对一定的Data Structure的操作。应该熟练掌握常见算法的实现。<br><br>5. Problem Base<br>&nbsp;&nbsp;&nbsp; 问题库就是各种类型的问题的集合，它们很典型，熟练掌握这些问题的算法分析设计对于解决新问题是绝对有好处的，遇到新问题时，通过类比，把未知规约成已知的解决过的问题。因此，储备很重要，应熟知各种经典问题。<br><br>这五点的关系可以用下图形象化地表示（用graphviz画图）：<br><br><br><img height=379 alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/Untitled8.jpg" width=504 border=0><br><br></p>
<img src ="http://www.cnitblog.com/houcy/aggbug/64071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-01-30 18:02 <a href="http://www.cnitblog.com/houcy/archive/2010/01/30/64071.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>《How to Solve It》 收藏</title><link>http://www.cnitblog.com/houcy/archive/2010/01/30/64070.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sat, 30 Jan 2010 09:26:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/01/30/64070.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/64070.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/01/30/64070.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/64070.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/64070.html</trackback:ping><description><![CDATA[<span style="FONT-FAMILY: Lucida Console"><font face=CMR10 size=2><font face=CMR10 size=2>
<p style="FONT-SIZE: 12pt" align=left>Problem-solving is not a science, but part art and part skill. It is one of the skills most worth developing.<br></font></font>解题不是一门科学，而是一种技艺，是最应该培养的技艺之一。这里所说的问题可以是学习、工作、生活中的任意问题，按照数学大师波利亚的&#8220;如何解题&#8221;的思路，遇到问题时我们的思路就不至于freeze up，而是有章可循！<br><br>Summary taken from G.Polya' book "How to Solve It"</span></p>
<ol>
    <li><span style="FONT-FAMILY: Lucida Console">UNDERSTANDING THE PROBLEM </span>
    <ul>
        <li><span style="FONT-FAMILY: Lucida Console">First. You have to understand the problem. </span>
        <li><span style="FONT-FAMILY: Lucida Console">What is the unknown? What are the data? What is the condition? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Is it possible to satisfy the condition? Is the condition sufficient to determine the unknown? Or is it insufficient? Or redundant? Or contradictory? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Draw a figure. Introduce suitable notation. </span>
        <li><span style="FONT-FAMILY: Lucida Console">Separate the various parts of the condition. Can you write them down? </span></li>
    </ul>
    <li><span style="FONT-FAMILY: Lucida Console">DEVISING A PLAN </span>
    <ul>
        <li><span style="FONT-FAMILY: Lucida Console">Second. Find the connection between the data and the unknown. You may be obliged to consider auxiliary problems if an immediate connection cannot be found. You should obtain eventually a plan of the solution. </span>
        <li><span style="FONT-FAMILY: Lucida Console">Have you seen it before? Or have you seen the same problem in a slightly different form? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Do you know a related problem? Do you know a theorem that could be useful? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Look at the unknown! And try to think of a familiar problem having the same or a similar unknown. </span>
        <li><span style="FONT-FAMILY: Lucida Console">Here is a problem related to yours and solved before. Could you use it? Could you use its result? Could you use its method? Should you introduce some auxiliary element in order to make its use possible? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Could you restate the problem? Could you restate it still differently? Go back to definitions. </span>
        <li><span style="FONT-FAMILY: Lucida Console">If you cannot solve the proposed problem try to solve first some related problem. Could you imagine a more accessible related problem? A more general problem? A more special problem? An analogous problem? Could you solve a part of the problem? Keep only a part of the condition, drop the other part; how far is the unknown then determined, how can it vary? Could you derive something useful from the data? Could you think of other data appropriate to determine the unknown? Could you change the unknown or data, or both if necessary, so that the new unknown and the new data are nearer to each other? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Did you use all the data? Did you use the whole condition? Have you taken into account all essential notions involved in the problem? </span></li>
    </ul>
    <li><span style="FONT-FAMILY: Lucida Console">CARRYING OUT THE PLAN </span>
    <ul>
        <li><span style="FONT-FAMILY: Lucida Console">Third. Carry out your plan. </span>
        <li><span style="FONT-FAMILY: Lucida Console">Carrying out your plan of the solution, check each step. Can you see clearly that the step is correct? Can you prove that it is correct? </span></li>
    </ul>
    <li><span style="FONT-FAMILY: Lucida Console">Looking Back </span>
    <ul>
        <li><span style="FONT-FAMILY: Lucida Console">Fourth. Examine the solution obtained. </span>
        <li><span style="FONT-FAMILY: Lucida Console">Can you check the result? Can you check the argument? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Can you derive the solution differently? Can you see it at a glance? </span>
        <li><span style="FONT-FAMILY: Lucida Console">Can you use the result, or the method, for some other problem?</span> </li>
    </ul>
    </li>
</ol>
<img src ="http://www.cnitblog.com/houcy/aggbug/64070.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-01-30 17:26 <a href="http://www.cnitblog.com/houcy/archive/2010/01/30/64070.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>好网站收藏</title><link>http://www.cnitblog.com/houcy/archive/2010/01/23/63925.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sat, 23 Jan 2010 02:15:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2010/01/23/63925.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/63925.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2010/01/23/63925.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/63925.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/63925.html</trackback:ping><description><![CDATA[<br>程序在线运行：<br><a href="http://ideone.com/">http://ideone.com/</a><br><br>代码发芽网：<br><a href="http://fayaa.com/">http://fayaa.com/</a> 
<img src ="http://www.cnitblog.com/houcy/aggbug/63925.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2010-01-23 10:15 <a href="http://www.cnitblog.com/houcy/archive/2010/01/23/63925.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>操作系统进程调度算法在工作中的使用【原创】</title><link>http://www.cnitblog.com/houcy/archive/2009/11/01/62333.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Sun, 01 Nov 2009 07:30:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/11/01/62333.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/62333.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/11/01/62333.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/62333.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/62333.html</trackback:ping><description><![CDATA[&nbsp; 今早醒来躺床上看mp5里的电子书，虽然从网上下载了好多，但是还没认真看过，正好是周日有时间就躺在热窝里品读一番。一本关于时间管理的书，其中讲到了怎么处理工作中轻重缓急的事情，我不禁联想到操作系统对于进程的调度算法，感觉在工作中应该借鉴该调度算法，来合理调度处理事情，毕竟我们是IT人，更应该学会怎样用此法处理工作中的事情。<br><br>&nbsp;&nbsp;&nbsp; 关于操纵系统对进程的调度策略简要介绍一下，操作系统作为人机接口主要是对人提供友好易用的操作界面以及管理各种系统资源，比如如何在进程之间分配CPU、内存和I/O资源，资源是有限的，CPU的主频、内存的容量、I/O资源已经固定了，那么怎么合理地分配这些资源给诸多的进程使用呢？这就需要一个科学的调度算法。现在的主流操作系统几乎都是采用基于优先级的时间片轮转调度法，基于优先级又可分为抢占式和非抢占式调度，所谓抢占式就是允许高优先级的进程比当前进程优先执行，此时需要中断当前进程的执行，并做好簿记工作以备断点恢复，转而去做更高优先级的事情。也就是说每个进程都有一个优先级，并且都有运行时间，这说明优先级表明了进程的重要性，而处理时间则表明了进程的紧急性，一个设计良好的操作系统的大部分时间应该是在处理重要而不紧急的事情。<br>&nbsp;&nbsp;&nbsp; 基于上段知识，我们可以类比如下：<br><br>计算机&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 人<br>操作系统 &lt;--------&gt;&nbsp;&nbsp; 大脑<br>CPU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 脑神经<br>内存&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 脑容量<br>I/O&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 器官 <br>进程&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 处理的事情<br>时间&nbsp;&nbsp;&nbsp;&nbsp; &lt;--------&gt;&nbsp;&nbsp; 时间<br><br>&nbsp;&nbsp;&nbsp;&nbsp; 计算机的任务是在操作系统的管理下，合理分配CPU,内存，I/O等资源在有限的时间内完成进程的运行。人的任务是在身体硬件素质一定的情况下如何在有限的时间内处理事情。<br><br>&nbsp;&nbsp;&nbsp;&nbsp; 根据进程调度算法——基于优先级的时间片轮转调度法，我们把工作中要处理的事情赋予一定的优先级，也就是重要性，同时还要赋予一定的时间片，也就是在多长时间内完成事情，即设定事情的紧急性。这样我们做事的顺序是：先做重要且不紧急的事情，如果时间片分配合理，应该在规定时间内完成所有的重要不紧急的事情了，如果不幸没有能够在时间片内完成事情，则事情将变成重要且紧急，就此时它的优先级应该相应的提高，必须马上搞定才是，否则后果很严重；而对于紧急但不重要的事情（比如别人的电话、邮件回复、会议等），这些事情对别人来说是重要的，但是对自己来说只是紧急的，其优先级应该低于重要不紧急的事情，也就是先把自己的事情搞定再搞定别人的事情。但是很不幸，工作中大部分人是在做紧急且重要的事情和紧急但不重要的事情，疲于两者的结果是最终去做既不紧急也不重要的事情（不如浏览网页新闻、聊天、喝茶、打盹），因此工作效率必然不高。<br><br>&nbsp;&nbsp;&nbsp;&nbsp; 我们可以把要做的事情按重要性和紧急性两个维度来划分到四个象限去，这个是很经典的时间管理学的四象限法。<br><img height=449 alt="" src="http://www.cnitblog.com/images/cnitblog_com/houcy/asix.JPG" width=590 border=0><br>&nbsp;&nbsp;&nbsp; 如何把此法运用于实际工作中呢？<br>&nbsp;&nbsp; 1. 提前一刻钟到公司，写下今天将要做的事情，分析一下重要性和紧急性，然后排好顺序。<br>&nbsp;&nbsp; 2. 找个专门的工作记录本，记录每天的事情顺序列表<br>&nbsp;&nbsp; 3. 做事前先考虑一下事情应该是在哪个象限，并采取相应的做法。<br>&nbsp;&nbsp; 4. 下班后晚一刻钟离开，检查一天的事情完成情况，分析原因<br>&nbsp;<br>&nbsp;&nbsp; 我敢打赌，这样做了工作效率肯定提高！<br><br>
<img src ="http://www.cnitblog.com/houcy/aggbug/62333.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-11-01 15:30 <a href="http://www.cnitblog.com/houcy/archive/2009/11/01/62333.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>《Engineering A Compiler》 1. An Overview of Compilation【好书翻译】</title><link>http://www.cnitblog.com/houcy/archive/2009/08/13/60793.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 13 Aug 2009 15:52:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/08/13/60793.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/60793.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/08/13/60793.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/60793.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/60793.html</trackback:ping><description><![CDATA[<p style="FONT-SIZE: 12pt">An Overview of Compilation&nbsp; <br><br>【Syntax 】<br>In a compiler, this task is called syntax analysis. To perform syntax analysis efficiently, the compiler needs:<br>1. a formal definition of the source language,<br>2. an efficient membership test for the source language, and<br>3. a plan for how to handle illegal inputs.<br><br>&nbsp;&nbsp;&nbsp;Mathematically, the source language is a set, usually infinite, of strings defined by some finite set of rules. The compiler&#8217;s front end must determine whether the source program presented for compilation is, in fact, an element in that set of valid strings.<br><br>&nbsp;&nbsp;&nbsp;To keep the set of rules that define a language small, the rules typically refer to words by their syntactic categories, or parts of-speech, rather than individual words. In describing English, for example, this abstraction allows us to state that many sentences have the form：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sentence &#8594; subject verb object period&nbsp;<br>&nbsp;&nbsp;&nbsp;rather than trying to enumerate the set of all sentences. For example, we use a syntactic variable, verb, to represent all possible verbs. With English, the reader generally recognizes many thousand words and knows the possible partsof-speech that each can fulfill. For an unfamiliar string, the reader consults a dictionary. Thus, the syntactic structure of the language is based on a set of rules, or a grammar, and a system for grouping characters together to form words and for classifying those words into their syntactic categories.<br><br>To understand whether the sentence &#8220;Compilers are engineered objects.&#8221; is, in fact, a valid English sentence, we first establish that each word is valid. Next, each word is replaced by its syntactic category to create a somewhat more abstract representation of the sentence&#8211;noun verb adjective noun period Finally, we try to fit this sequence of abstracted words into the rules for an English sentence. A working knowledge of English grammar might include the following rules:<br>1 sentence &#8594; subject verb object<br>2 subject &#8594; noun<br>3 subject &#8594; modifier noun<br>4 object &#8594; noun<br>5 object &#8594; modifier noun<br>6 modifier &#8594; adjective<br>7 modifier &#8594; adjectival phrase<br>. . .<br><br>Here, the symbol &#8594; reads &#8220;derives&#8221; and means that an instance of the right hand side can be abstracted to the left hand side. By inspection, we can discover the following derivation for our example sentence.<br><br>Rule&nbsp;&nbsp;&nbsp;Prototype Sentence<br>-----------------------------<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sentence<br>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subject verb object period<br>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;noun verb object period<br>5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;noun verb modifier noun period<br>6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;noun verb adjective noun period<br><br>At this point, the prototype sentence generated by the derivation matches the abstract representation of our input sentence. Because they match, at this level of abstraction, we can conclude that the input sentence is a member of the language described by the grammar. This process of discovering a valid derivation for some stream of tokens is called parsing.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编译理论概览<br><br>【句法】<br>在编译器中，这项任务称作&#8220;句法分析&#8221;，为了有效地分析句法，编译器需要如下几条：<br>1. 源语言的形式化定义<br>2. 有效测试源语言的成员性<br>3. 对于如何处理非法输入的计划<br><br>&nbsp;&nbsp;&nbsp;从数学角度来说，源语言通常是有穷规则集定义的字符串的无穷集。编译器的前端必须决定待编译的源程序事实上是前述有效字符串集合的一个元素。<br><br>&nbsp;&nbsp;&nbsp;为了使得定义语言的规则的集合小，规则通常指代词的句法属类，或是词性，而不是单个的词。比如，在描述英语时，这种抽象使得我们可以声明很多有同样的形式句子：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;句子&nbsp; —&gt; 主语&nbsp; 动词&nbsp;&nbsp; 宾语 句号<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;而不是试图枚举集合中的所有句子。 比如，我们用一个句法变量"verb"代表所有可能的动词。对于英语，读者通常认得上千单词，知道每个需要填的词性。 对于不熟悉的字符串，读者求助词典。因此，语言的句法结构是基于规则集合或语法，以及基于把字符组合一起形成单词并把这些单词分成句法属类。<br><br>&nbsp;&nbsp;&nbsp;为了理解句子&#8220;编译器是构造出来的客体&#8221;是一句有效的句子，问首先确立每个单词是有效的。接着，每个词由它的句法属类代替，以此生成稍微更抽象的句子表达——名词 动词 形容词 名词 句号。最后，我们试图使这个由抽象词组成的句子符合规则集描述的英语句子。有用的英语语法可能包括如下规则：<br>1. 句子 —》 主语 动词 宾语<br>2. 主语 —》 名词<br>3. 主语 —》 修饰符 名词<br>4. 宾语 —》 名词<br>5. 宾语 —》 修饰符 名词<br>6. 修饰符 —》 形容词<br>7. 修饰符 —》 形容词短语<br>。。。<br><br>这里符号—》读作&#8220;派生&#8221;，意指右边的实例可以被抽象成左边的东东。通过检查，我们能够发现我们的示例句子可以这样派生出来：<br><br>规则&nbsp;&nbsp;&nbsp;句子原型<br>------------------------------<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;句子<br>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主语 动词 宾语 句号<br>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名词 动词 宾语 句号<br>5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名词 动词 修饰符 名词 句号<br>6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名词 动词 形容词 名词 句号<br><br>到此为止，通过派生得出的句子原型与我们的输入句子的抽象表达完全匹配。因为它们在抽象层次匹配，我们可以得出结论：输入的句子是由语法描述的语言的一个组成成员。对于符号流发现一个有效派生的过程成为解析。<br><br><br>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</p>
<p style="FONT-SIZE: 12pt">读书笔记：<br>1. 编译器需要知道源语言的形式化定义，即由有穷规则描述的形式化的语法，这样才能在语法空间里派生出一个句子原型，然后把该原型与输入句子的抽象描述进行匹配。如果完全匹配，则说明输入的句子确实是目标语言的一个句子，也即语言空间里的一个元素。<br>2. 对于计算机编程语言来说，把输入的指令句子，如 int x=3; 分割成符号流 int x = 3 ;&nbsp;然后抽象成语法变量描述：keyword id operator number ;&nbsp; 然后再在语言的文法空间里查找是否有可以派生出一条句子原型与这个抽象描述匹配。<br><br>3. at this point&nbsp; 在这一点上<br>&nbsp;&nbsp;&nbsp;Could I put in a word at this point? 我现在说几句行吗？<br>&nbsp;&nbsp;&nbsp;At this point, your logic is at fault. 在这一点上你的推理是错误的。<br>4. right hand side, left hand side 右边、左边<br>5. fit into&nbsp; vt. 适应、符合<br></p>
<img src ="http://www.cnitblog.com/houcy/aggbug/60793.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-08-13 23:52 <a href="http://www.cnitblog.com/houcy/archive/2009/08/13/60793.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一些牛人的博客【收藏】</title><link>http://www.cnitblog.com/houcy/archive/2009/07/20/60239.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Mon, 20 Jul 2009 12:01:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/07/20/60239.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/60239.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/07/20/60239.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/60239.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/60239.html</trackback:ping><description><![CDATA[自己整理了一些牛人的技术博客，特收藏于此：<br><br><a href="http://blog.youxu.info/">http://blog.youxu.info/</a>&nbsp;&nbsp; 博主徐宥, 一个计算机专业的 Ph.D. 学生<br><a href="http://mindhacks.cn/">http://mindhacks.cn</a>&nbsp; 博主刘未鹏，南京大学毕业的，好像现在微软工作，他的博文充满了数学和哲学思考，很有技术含量！<br><a href="http://blog.solrex.cn/">http://blog.solrex.cn/</a>&nbsp; 博主是中科院的研究生<br><a href="http://blog.csdn.net/liwei_cmg/">http://blog.csdn.net/liwei_cmg/</a>&nbsp; 博主草木瓜，写的lex &amp; yacc博文很值得学习！<br><a href="http://cuitianyi.com/">http://cuitianyi.com/</a>&nbsp; 博主DD<br><a href="http://www.matrix67.com/blog/">http://www.matrix67.com/blog/</a>&nbsp; 博主Matrix<br><a href="http://blog.codingnow.com/">http://blog.codingnow.com/</a>&nbsp; 博主云风<br><a href="http://blog.csdn.net/absurd/">http://blog.csdn.net/absurd/</a>&nbsp; <br><a href="http://blog.csdn.net/turingbook">http://blog.csdn.net/turingbook</a><br><a href="http://blog.csdn.net/chinalinuxzend">http://blog.csdn.net/chinalinuxzend<br></a><a href="http://www.cppblog.com/abilitytao/">http://www.cppblog.com/abilitytao/</a><br><a href="http://blog.donews.com/gradetwo/">http://blog.donews.com/gradetwo/</a><br><br><br>关于ACM的博客：<br><a href="http://hi.baidu.com/xiapingwen">http://hi.baidu.com/xiapingwen</a>&nbsp; <br><a href="http://acm.zjuwinsty.cn/">http://acm.zjuwinsty.cn/</a>&nbsp; <br><a href="http://www.cppblog.com/Darren/">http://www.cppblog.com/Darren/</a><br><a href="http://blog.csdn.net/chinalinuxzend"><br></a><br>老外的博客/主页：<br><a href="http://www.cs.sunysb.edu/~skiena/">http://www.cs.sunysb.edu/~skiena/</a>&nbsp;&nbsp; 纽约石溪大学计算机系教授Steven Skiena的主页<br><a href="http://burtleburtle.net/bob/index.html">http://burtleburtle.net/bob/index.html</a>&nbsp; 
<img src ="http://www.cnitblog.com/houcy/aggbug/60239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-07-20 20:01 <a href="http://www.cnitblog.com/houcy/archive/2009/07/20/60239.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The 25 most difficult questions you'll be asked on a job interview 【转】</title><link>http://www.cnitblog.com/houcy/archive/2009/06/29/59711.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Mon, 29 Jun 2009 06:34:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/06/29/59711.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/59711.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/06/29/59711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/59711.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/59711.html</trackback:ping><description><![CDATA[<h2>Being prepared is half the battle.</h2>
<blockquote><em>If you are one of those executive types unhappy at your present post and embarking on a New Year's resolution to find a new one, here's a helping hand. The job interview is considered to be the most critical aspect of every expedition that brings you face-to- face with the future boss. One must prepare for it with the same tenacity and quickness as one does for a fencing tournament or a chess match.</em> </blockquote>
<blockquote><em>This article has been excerpted from "PARTING COMPANY: How to Survive the Loss of a Job and Find Another Successfully" by William J. Morin and James C. Cabrera. Copyright by Drake Beam Morin, inc. Publised by Harcourt Brace Jovanovich.</em> </blockquote>
<blockquote><strong>Morin is chairman and Cabrera is president of New York-based Drake Beam Morin, nation's major outplacement firm, which has opened offices in Philadelphia.</strong> </blockquote>
<h3>1. Tell me about yourself.</h3>
<p>Since this is often the opening question in an interview, be extracareful that you don't run off at the mouth. Keep your answer to a minute or two at most. Cover four topics: early years, education, work history, and recent career experience. Emphasize this last subject. Remember that this is likely to be a warm-up question. Don't waste your best points on it.
<h3>2. What do you know about our organization?</h3>
<p>You should be able to discuss products or services, revenues, reputation, image, goals, problems, management style, people, history and philosophy. But don't act as if you know everything about the place. Let your answer show that you have taken the time to do some research, but don't overwhelm the interviewer, and make it clear that you wish to learn more.
<p>You might start your answer in this manner: "In my job search, I've investigated a number of companies.
<p>Yours is one of the few that interests me, for these reasons..."
<p>Give your answer a positive tone. Don't say, "Well, everyone tells me that you're in all sorts of trouble, and that's why I'm here", even if that is why you're there.
<h3>3. Why do you want to work for us?</h3>
<p>The deadliest answer you can give is "Because I like people." What else would you like-animals?
<p>Here, and throughout the interview, a good answer comes from having done your homework so that you can speak in terms of the company's needs. You might say that your research has shown that the company is doing things you would like to be involved with, and that it's doing them in ways that greatly interest you. For example, if the organization is known for strong management, your answer should mention that fact and show that you would like to be a part of that team. If the company places a great deal of emphasis on research and development, emphasize the fact that you want to create new things and that you know this is a place in which such activity is encouraged. If the organization stresses financial controls, your answer should mention a reverence for numbers. </p>
<p>If you feel that you have to concoct an answer to this question - if, for example, the company stresses research, and you feel that you should mention it even though it really doesn't interest you- then you probably should not be taking that interview, because you probably shouldn't be considering a job with that organization.
<p>Your homework should include learning enough about the company to avoid approaching places where you wouldn't be able -or wouldn't want- to function. Since most of us are poor liars, it's difficult to con anyone in an interview. But even if you should succeed at it, your prize is a job you don't really want.
<h3>4. What can you do for us that someone else can't?</h3>
<p>Here you have every right, and perhaps an obligation, to toot your own horn and be a bit egotistical. Talk about your record of getting things done, and mention specifics from your resume or list of career accomplishments. Say that your skills and interests, combined with this history of getting results, make you valuable. Mention your ability to set priorities, identify problems, and use your experience and energy to solve them.
<h3>5. What do you find most attractive about this position? What seems least attractive about it?</h3>
<p>List three or four attractive factors of the job, and mention a single, minor, unattractive item.
<h3>6. Why should we hire you?</h3>
<p>Create your answer by thinking in terms of your ability, your experience, and your energy. (See question 4.)
<h3>7. What do you look for in a job?</h3>
<p>Keep your answer oriented to opportunities at this organization. Talk about your desire to perform and be recognized for your contributions. Make your answer oriented toward opportunity rather than personal security.
<h3>8. Please give me your defintion of [the position for which you are being interviewed].</h3>
<p>Keep your answer brief and taskoriented. Think in in terms of responsibilities and accountability. Make sure that you really do understand what the position involves before you attempt an answer. If you are not certain. ask the interviewer; he or she may answer the question for you.
<h3>9. How long would it take you to make a meaningful contribution to our firm?</h3>
<p>Be realistic. Say that, while you would expect to meet pressing demands and pull your own weight from the first day, it might take six months to a year before you could expect to know the organization and its needs well enough to make a major contribution.
<h3>10. How long would you stay with us?</h3>
<p>Say that you are interested in a career with the organization, but admit that you would have to continue to feel challenged to remain with any organization. Think in terms of, "As long as we both feel achievement-oriented."
<h3>11. Your resume suggests that you may be over-qualified or too experienced for this position. What's Your opinion?</h3>
<p>Emphasize your interest in establishing a long-term association with the organization, and say that you assume that if you perform well in his job, new opportunities will open up for you. Mention that a strong company needs a strong staff. Observe that experienced executives are always at a premium. Suggest that since you are so wellqualified, the employer will get a fast return on his investment. Say that a growing, energetic company can never have too much talent.
<h3>12. What is your management style?</h3>
<p>You should know enough about the company's style to know that your management style will complement it. Possible styles include: task oriented (I'll enjoy problem-solving identifying what's wrong, choosing a solution and implementing it"), results-oriented ("Every management decision I make is determined by how it will affect the bottom line"), or even paternalistic ("I'm committed to taking care of my subordinates and pointing them in the right direction").
<p>A participative style is currently quite popular: an open-door method of managing in which you get things done by motivating people and delegating responsibility.
<p>As you consider this question, think about whether your style will let you work hatppily and effectively within the organization.
<h3>13. Are you a good manager? Can you give me some examples? Do you feel that you have top managerial potential?</h3>
<p>Keep your answer achievementand ask-oriented. Rely on examples from your career to buttress your argument. Stress your experience and your energy.
<h3>14. What do you look for when You hire people?</h3>
<p>Think in terms of skills. initiative, and the adaptability to be able to work comfortably and effectively with others. Mention that you like to hire people who appear capable of moving up in the organization.
<h3>15. Have you ever had to fire people? What were the reasons, and how did you handle the situation?</h3>
<p>Admit that the situation was not easy, but say that it worked out well, both for the company and, you think, for the individual. Show that, like anyone else, you don't enjoy unpleasant tasks but that you can resolve them efficiently and -in the case of firing someone- humanely.
<h3>16. What do you think is the most difficult thing about being a manager or executive?</h3>
<p>Mention planning, execution, and cost-control. The most difficult task is to motivate and manage employess to get something planned and completed on time and within the budget.
<h3>17. What important trends do you see in our industry?</h3>
<p>Be prepared with two or three trends that illustrate how well you understand your industry. You might consider technological challenges or opportunities, economic conditions, or even regulatory demands as you collect your thoughts about the direction in which your business is heading.
<h3>18. Why are you leaving (did you leave) your present (last) job?</h3>
<p>Be brief, to the point, and as honest as you can without hurting yourself. Refer back to the planning phase of your job search. where you considered this topic as you set your reference statements. If you were laid off in an across-the-board cutback, say so; otherwise, indicate that the move was your decision, the result of your action. Do not mention personality conflicts.
<p>The interviewer may spend some time probing you on this issue, particularly if it is clear that you were terminated. The "We agreed to disagree" approach may be useful. Remember hat your references are likely to be checked, so don't concoct a story for an interview.
<h3>19. How do you feel about leaving all your benefits to find a new job?</h3>
<p>Mention that you are concerned, naturally, but not panicked. You are willing to accept some risk to find the right job for yourself. Don't suggest that security might interest you more than getting the job done successfully.
<h3>20. In your current (last) position, what features do (did) you like the most? The least?</h3>
<p>Be careful and be positive. Describe more features that you liked than disliked. Don't cite personality problems. If you make your last job sound terrible, an interviewer may wonder why you remained there until now.
<h3>21. What do you think of your boss?</h3>
<p>Be as positive as you can. A potential boss is likely to wonder if you might talk about him in similar terms at some point in the future.
<h3>22. Why aren't you earning more at your age?</h3>
<p>Say that this is one reason that you are conducting this job search. Don't be defensive.
<h3>23. What do you feel this position should pay?</h3>
<p>Salary is a delicate topic. We suggest that you defer tying yourself to a precise figure for as long as you can do so politely. You might say, "I understand that the range for this job is between $______ and $______. That seems appropriate for the job as I understand it." You might answer the question with a question: "Perhaps you can help me on this one. Can you tell me if there is a range for similar jobs in the organization?"
<p>If you are asked the question during an initial screening interview, you might say that you feel you need to know more about the position's responsibilities before you could give a meaningful answer to that question. Here, too, either by asking the interviewer or search executive (if one is involved), or in research done as part of your homework, you can try to find out whether there is a salary grade attached to the job. If there is, and if you can live with it, say that the range seems right to you.
<p>If the interviewer continues to probe, you might say, "You know that I'm making $______ now. Like everyone else, I'd like to improve on that figure, but my major interest is with the job itself." Remember that the act of taking a new job does not, in and of itself, make you worth more money.
<p>If a search firm is involved, your contact there may be able to help with the salary question. He or she may even be able to run interference for you. If, for instance, he tells you what the position pays, and you tell him that you are earning that amount now and would Like to do a bit better, he might go back to the employer and propose that you be offered an additional 10%.
<p>If no price range is attached to the job, and the interviewer continues to press the subject, then you will have to restpond with a number. You cannot leave the impression that it does not really matter, that you'll accept whatever is offered. If you've been making $80,000 a year, you can't say that a $35,000 figure would be fine without sounding as if you've given up on yourself. (If you are making a radical career change, however, this kind of disparity may be more reasonable and understandable.)
<p>Don't sell yourself short, but continue to stress the fact that the job itself is the most important thing in your mind. The interviewer may be trying to determine just how much you want the job. Don't leave the impression that money is the only thing that is important to you. Link questions of salary to the work itself.
<p>But whenever possible, say as little as you can about salary until you reach the "final" stage of the interview process. At that point, you know that the company is genuinely interested in you and that it is likely to be flexible in salary negotiations.
<h3>24. What are your long-range goals?</h3>
<p>Refer back to the planning phase of your job search. Don't answer, "I want the job you've advertised." Relate your goals to the company you are interviewing: 'in a firm like yours, I would like to..."
<h3>25. How successful do you you've been so far?</h3>
<p>Say that, all-in-all, you're happy with the way your career has progressed so far. Given the normal ups and downs of life, you feel that you've done quite well and have no complaints.
<p>Present a positive and confident picture of yourself, but don't overstate your case. An answer like, "Everything's wonderful! I can't think of a time when things were going better! I'm overjoyed!" is likely to make an interviewer wonder whether you're trying to fool him . . . or yourself. The most convincing confidence is usually quiet confidence. </p>
<img src ="http://www.cnitblog.com/houcy/aggbug/59711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-06-29 14:34 <a href="http://www.cnitblog.com/houcy/archive/2009/06/29/59711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Open Testware Reviews---GUI Test Driver Survey【收藏】</title><link>http://www.cnitblog.com/houcy/archive/2009/04/08/56168.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Wed, 08 Apr 2009 12:05:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/04/08/56168.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/56168.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/04/08/56168.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/56168.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/56168.html</trackback:ping><description><![CDATA[<h1><span style="FONT-STYLE: italic">Open Testware Reviews</span><br></h1>
<h1><strong>GUI Test Driver Survey</strong></h1>
<div style="TEXT-ALIGN: left"><small>Copyright 2003 by Tejas Software Consulting - All rights reserved</small>.<br></div>
<br><span style="FONT-WEIGHT: bold">Reviewed:</span> 2003-May-30<br><span style="FONT-WEIGHT: bold"></span><span style="FONT-WEIGHT: bold">Testingfaqs.org category:</span> <a href="http://testingfaqs.org/t-gui.html"><u><font color=#606420>GUI Test Drivers</font></u></a><br><br>Testingfaqs.org gets a big boost for freeware GUI test tools this month. Seventeen freeware tools are now listed on the GUI Test Drivers list, rather than just the three we had before (Android, Jemmy, and Test Now). <br>
<h3>Scope</h3>
GUI test tools are primarily functional test harnesses, like those on the "Test Drivers and Test Suite Management Tools" list, except that they specialize in automating a graphical user interface (GUI). Some GUI tools rely on other harnesses like JUnit, and focus on providing the mechanisms for faking mouse and keyboard input, similar to the way the commercial WinRunner tool interfaces with TestDirector.<br>
<h3>About GUI testing</h3>
There has long been a dialog within the testing community about the difficulties of GUI test automation. Early GUI test tools were all "analog," which means that they record mouse movements using X-Y screen coordinates (which are measured digitally, but let's not pick nits :-) like those you used in school when you studied geometry. Analog capture and replay of test scripts is a very poor GUI test automation technique. They require a tremendous amount of maintenance every time the GUI design of the application under test changes, and in fact all of the test scripts may need to be recreated from scratch when then is a very minor change to the GUI. Analog scripts may also be sensitive to changes in screen resolution, color depth, and even where the window is placed on the screen. In most situations, it's better not to automate your GUI tests at all if your only choice is an analog tool.<br><br>Any modern GUI test tool worth its salt is "object-based," which means it can recognize many of the controls in a graphical application, like buttons, menus, and text input widgets, and can refer to them symbolically rather than with raw screen coordinates. This technique is much more resilient to changes in the GUI design, screen resolution, etc., though of course the tests will still need changes if a GUI control is added or deleted outright. A common limitation of an object-based tool is that it may have trouble automatically recognizing all of the controls in the application, especially if the developers use custom-developed controls or a toolkit that the tool isn't trained to understand. Object-based tools typically can also use analog-style screen coordinates if necessary.<br><br>One way to reduce the maintenance of a test case with analog-style scripting is to create a library that isolates all screen coordinate references to low-level functions. If the test cases only use these functions and never refer directly to screen coordinates, then when (not if) the application changes, most of the maintenance will be isolated to the test library. Still, that might represent significant effort. It may only be feasible to automate a small smoke test that's executed very frequently, rather than a large swath of functional tests.<br><br>There are some additional tool features that can further reduce test maintenance. One is "data-driven" testing. If you want to run the same test code repeatedly with only the test data varying from one run to the next, you can specify the data separately and have the script loop through each data value one at a time. Several commercial tools support this. <br><br>A more ambitious idea is "keyword-driven" testing. This involves specifying test data as with data-driven testing, but also uses pre-defined keywords to define actions for a test case to take. The keywords represent a very simple specification language that non-programmers may be able to use to directly develop automated tests. You still need automation engineers to implement the things that the keywords do, and with that comes all the usual issues of GUI automation. I know of two commercial tools that support keyword-driven testing - <a href="http://testingfaqs.org/t-gui.html#Certify"><u><font color=#606420>Certify</font></u></a> from Worksoft, and the ABT Toolset (contact <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#98;&#117;&#119;&#97;&#108;&#100;&#97;&#64;&#104;&#97;&#112;&#112;&#121;&#116;&#101;&#115;&#116;&#101;&#114;&#46;&#99;&#111;&#109;"><u><font color=#0000ff>Hans Buwalda</font></u></a> for a fact sheet). Hans also writes about this topic in his book?<em>Integrated Test Design and Automation: Using the Test Frame Method. <br></em>
<h3>Comments on what you'll find here</h3>
Approach freeware GUI tools with caution. Looking at the documentation, it's very difficult to tell which of them support object-based automation. Building an analog GUI test tool is much easier than building an object-based tool, so I suspect that most of these tools are not object-aware.<br><br>Several of the tools are specific to Microsoft Windows - the documentation usually does not specify which Windows releases are supported. There are two here that are specific to one or more Unix variant. And there's the large subset of Java-based tools that presumably run across many platforms, but probably only for applications written in Java.<br><br>There are two freeware keyword-driven frameworks - EMOS Framework and SAFS, both only supported on Windows. Like their commercial counterparts, they are designed as wrappers on top of a limited selection of commercial test tools and can't easily stand on their own. You might hear about a data-driven tool called Robot DDE -- it has now been incorporated into SAFS. <br><br>Test Now is a library designed as an aid for another commercial test tool, Visual Test, though only for an outdated version of it. You can find a motley collection of other freeware code snippets for commercial GUI tools at the <a href="http://qadownloads.com/"><u><font color=#0000ff>QA Downloads</font></u></a> site.<br><br>A few tools have a graphical interface themselves, but most are implemented as libraries. Some can capture test scripts when you use the application under test, and the others require you to develop test scripts from scratch. A few of the Windows libraries are DLL's that can be used from many different languages. Several of the libraries are designed only for one language.<br>
<h3>And now, the list?</h3>
<table style="WIDTH: 100%; TEXT-ALIGN: left" cellSpacing=2 cellPadding=2 border=1>
    <tbody>
        <tr>
            <td style="VERTICAL-ALIGN: top"><span style="FONT-WEIGHT: bold">Tool</span><br></td>
            <td style="VERTICAL-ALIGN: top"><span style="FONT-WEIGHT: bold">Platforms</span><br></td>
            <td style="VERTICAL-ALIGN: top"><span style="FONT-WEIGHT: bold">Notes</span><br></td>
        </tr>
        <tr>
            <td style="VERTICAL-ALIGN: top"><a href="http://testingfaqs.org/t-gui.html#Abbot"><u><font color=#606420>Abbot</font></u></a><br></td>
            <td style="VERTICAL-ALIGN: top">Java<br></td>
            <td style="VERTICAL-ALIGN: top">GUI test library, with apparently some object-based recording capabilities<br></td>
        </tr>
        <tr>
            <td style="VERTICAL-ALIGN: top"><a href="http://testingfaqs.org/t-gui.html#Android"><u><font color=#606420>Android</font></u></a><br></td>
            <td style="VERTICAL-ALIGN: top">Unix<br></td>
            <td style="VERTICAL-ALIGN: top">Tcl/Tk extension for X11 testing, seems to be analog-only<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#AutoIt"><u><font color=#606420>AutoIt</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>Scripting language for analog GUI automation, also available as an ActiveX control and a DLL<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#EMOS_Framework"><u><font color=#606420>EMOS Framework</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>Keyword-driven test framework for WinRunner, test cases are stored in spreadsheets<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Jacareto"><u><font color=#606420>Jacareto</font></u></a><br></td>
            <td vAlign=top>Java<br></td>
            <td vAlign=top>Capture/replay tool.<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Jemmy"><u><font color=#606420>Jemmy</font></u></a><br></td>
            <td vAlign=top>Java<br></td>
            <td vAlign=top>GUI test library for Java Swing/AWT<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#jfcUnit"><u><font color=#606420>jfcUnit</font></u></a><br></td>
            <td vAlign=top>Java<br></td>
            <td vAlign=top>JUnit extension for testing Java Swing applications, with event recording<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Marathon"><u><font color=#606420>Marathon</font></u></a><br></td>
            <td vAlign=top>Java<br></td>
            <td vAlign=top>Python library for testing Java Swing applications<br></td>
        </tr>
        <tr>
            <td style="VERTICAL-ALIGN: top"><a href="http://testingfaqs.org/t-gui.html#Win32::GUITest"><u><font color=#606420>Perl Win32::GuiTest</font></u></a><br></td>
            <td style="VERTICAL-ALIGN: top">Windows<br></td>
            <td style="VERTICAL-ALIGN: top">GUI test library for Perl on Windows<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#X11::GUITest"><u><font color=#606420>Perl X11::GUITest</font></u></a><br></td>
            <td vAlign=top>Linux/FreeBSD<br></td>
            <td vAlign=top>GUI test library for Perl on X11<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Phantom"><u><font color=#606420>Phantom</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>GUI scripting language, newer tools based on Phantom are available commercially<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Pounder"><u><font color=#606420>Pounder</font></u></a><br></td>
            <td vAlign=top>Java<br></td>
            <td vAlign=top>Capture/replay tool<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Ruby_Win32::GuiTest"><u><font color=#606420>Ruby Win32::GuiTest </font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>The beginnings of a port of Perl's Win32::GuiTest to Ruby<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#SAFS"><u><font color=#606420>SAFS (Software Automation Framework Support)</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>Keyword-driven test framework for Rational Robot and WinRunner.<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#testnow"><u><font color=#606420>Test Now</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>Add-on library for Visual Test 4.0.<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#Tester"><u><font color=#606420>Tester</font></u></a><br></td>
            <td vAlign=top>Windows<br></td>
            <td vAlign=top>GUI test DLL with analog capture/replay<br></td>
        </tr>
        <tr>
            <td vAlign=top><a href="http://testingfaqs.org/t-gui.html#TRecorder"><u><font color=#606420>TRecorder</font></u></a><br></td>
            <td vAlign=top>unknown<br></td>
            <td vAlign=top>A capture/replay tool implemented in Delphi<br></td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cnitblog.com/houcy/aggbug/56168.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-04-08 20:05 <a href="http://www.cnitblog.com/houcy/archive/2009/04/08/56168.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>国外知名大学教学课件视频【收藏】</title><link>http://www.cnitblog.com/houcy/archive/2009/03/17/55491.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Tue, 17 Mar 2009 06:50:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/03/17/55491.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/55491.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/03/17/55491.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/55491.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/55491.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">以下链接可能部分有效，本人只点击了几个，均好用，疯狂下载美帝国主义大学的资料，师夷长技以制夷，O(&#8745;_&#8745;)O哈哈</span><span style="COLOR: #000000">~</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>一、伯克利&nbsp;<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>加州大学伯克利分校&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">webcast.berkeley.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">courses.php<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>作为美国第一的公立大学，伯克利分校提供了许多优秀教授的播客和视频讲座，可以跟踪最新的讲座。想看教授布置的作业和课堂笔记，可以点击该教授的网页，通常，他</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">她都会第一堂课留下网址。实在不行，用google搜搜吧！<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>　　伯克利的视频都是.rm格式，请注意转换<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>　　二、麻省<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>麻省理工学院&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.mit.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">OcwWeb</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">web</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">courses</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">courses</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.htm<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>麻省理工是免费开放教育课件的先驱，计划在今年把１８００门课程的课件都放在网站上，提供课程与作业的ＰＤＦ格式下载。三是，麻省理工只提供少数的视频讲座。坐过学生上麻省有一个绝对优势，麻省理工在中国大陆和中国台湾都建立了镜像网站，把麻省的课程都翻译成立中文。鉴于ＰＤＦ格式，推荐使用ＦｏｘＩｔ　Ｒｅａｄｅｒ。<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>　　www.core.org.cn（中国大陆）推荐<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>　　www.myoops.org（中国台湾）<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>二、卡耐基梅隆&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.cmu.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">oli</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>卡耐基梅隆针对初入大学的大学生，提供１０门学科的课程视频。与其他大学的免费课程一样，非卡耐基梅隆的学子能学习课程，但是为了使学生能够及时了解自己的课程进度，卡耐基梅隆建议造访者在网站上注册，建立自己的资料库。这样一来，你得在有限的时间内完成一门课程，还要参加几次考试，当然，即使你得了１００分，卡耐基梅隆也不会给你开证明，更不会给你学分。<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>四、犹他<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>犹他大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.usu.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">front</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">page</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Courese_listing<br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>犹他大学类似于麻省理工，提供大量的课程课件<br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>五、塔夫茨<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>塔夫茨大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.tufts.edu<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>塔夫茨大学也是&#8220;开放式教育课程&#8221;的先驱之一，初期提供的课程着重在本校专长的生命科学、跨领域方法、国际观点以及对美国地区性、全国性社群服务的基础理论。<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>六、公开<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>英国公开大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">openlearn.open.ac.uk</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">course</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.php<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>英国十几所大学联合起来，组建了英国公开大学。有一部分课程是对注册学生开放的，但是有一批很好的课程是免费的，并提供视频。每门课还设立了论坛，在社区中，大家发表意见，提供其他的学习资源，互相取经。在这个网站里，最能锻炼自学者的能力，因为你要不停地淘，才能找到宝贝。<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>七、约翰霍普金斯<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>约翰霍普金斯&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.jhsph.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">topics.cfm<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>只有极少数人能够进入约翰霍普金斯大学就读，但是，现如今有动机的人不用花一分钱，便能通过网站获得该校的前沿知识。约翰霍普金斯提供了本学院最受欢迎的课程，包括青少年健康、行为和健康、生物统计学、环境、一般公共卫生、卫生政策、预防伤害、母亲和儿童健康、心理卫生、营养、人口科学、公共卫生准备和难民卫生等。<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>八、Connexions<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">cnx.rice.edu<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>CNX.org由莱斯大学开发，号称是课程资源免费共享图书馆。与其他大学不同的事，CNX邀请教授学者建立自己的社区，把自己的最新成果公布于世，接受大家的评价。可以说CNX开辟了大学资源共享的新天地，尤其适合自学能力超强的大学生。有些课程有中文版。<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>九、索菲亚<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>索菲亚大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">sofia.ocw.cn</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">gallery<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>无论是想当一名管理者、作家、评论员、还是要从事设计和IT业的人，索菲亚大学的免费课程肯定让你受益匪浅。索菲亚大学提供了8门学科的课程，其中《企业网络安全实战》已翻译成中文。<br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>十、华盛顿<br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>华盛顿大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.cs.washington.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">education</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">course</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">webs.html<br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>华盛顿大学的计算机工程学比较强，相关的几百门课程都已经放到网上。不但本科生能找到所需要的课程，连研究生也能淘到宝贝。该网站还提供特色讲座，比如：妇女、计算机与合作。课程不但提供讲座介绍、课堂笔记、有些课程还提供视频。<br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>牛津、斯坦福、耶鲁大学联合网站<br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.alllearn.org<br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>哥伦比亚大学<br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ci.columbia.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">ci<br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>伯克利音乐学院<br></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.berkleeshares.com<br></span><span style="COLOR: #008080">42</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>杜克大学法律中心<br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.law.duke.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">cspd</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">lectures<br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>圣母大学<br></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.nd.edu<br></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>英国格雷莎姆学院<br></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.gresham.ac.uk</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">default.asp<br></span><span style="COLOR: #008080">48</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>加州大学Irvine分校<br></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.uci.edu<br></span><span style="COLOR: #008080">50</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>富布莱特学校<br></span><span style="COLOR: #008080">51</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.fetp.edu.vn</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">home.cfm<br></span><span style="COLOR: #008080">52</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>日本东京大学<br></span><span style="COLOR: #008080">53</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.u</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">tokyo.ac.jp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">english<br></span><span style="COLOR: #008080">54</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>日本早稻田大学<br></span><span style="COLOR: #008080">55</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.waseda.jp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">ocw</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.html<br></span><span style="COLOR: #008080">56</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>日本大阪大学<br></span><span style="COLOR: #008080">57</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">ocw.osaka</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">u.ac.jp</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.php<br></span><span style="COLOR: #008080">58</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>法国巴黎高科<br></span><span style="COLOR: #008080">59</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">graduateschool.paristech.org<br></span><span style="COLOR: #008080">60</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">61</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">62</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>看大学视频播客：<br></span><span style="COLOR: #008080">63</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br></span><span style="COLOR: #008080">64</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>斯坦福大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">itunes.stanford.edu&nbsp;<br></span><span style="COLOR: #008080">65</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>加州大学伯克利分校http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">itunes.berkeley.edu<br></span><span style="COLOR: #008080">66</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>普渡大学http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">boilercast.itap.purdue.edu:</span><span style="COLOR: #000000">1013</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Boilercast<br></span><span style="COLOR: #008080">67</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>美国西南理工http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">pocast.swtc.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">lecture</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.php<br></span><span style="COLOR: #008080">68</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>加州大学洛杉矶分校http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.bruincast.ucla.edu<br></span><span style="COLOR: #008080">69</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>西肯塔基大学http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">blog.wku.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcasts&nbsp;<br></span><span style="COLOR: #008080">70</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Dupage学院http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.cod.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">multimedia</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcast</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">CODcast</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Welcome.html<br></span><span style="COLOR: #008080">71</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>纽约城市大学http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">podcast.york.cuny.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">lectures<br></span><span style="COLOR: #008080">72</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>莱斯大学http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">webcast.rice.edu<br></span><span style="COLOR: #008080">73</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>加州大学圣地亚哥分校http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">podcast.ucsd.edu<br></span><span style="COLOR: #008080">74</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>剑桥大学http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">mediaplayer.group.cam.ac.uk</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">main</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Podcasts.html<br></span><span style="COLOR: #008080">75</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>美国大学华盛顿法律学院&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.wcl.american.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcasts<br></span><span style="COLOR: #008080">76</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>杜克大学法律学院http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.law.duke.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">webcast<br></span><span style="COLOR: #008080">77</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>乔治敦大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">webcast.georgetown.edu<br></span><span style="COLOR: #008080">78</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>芝加哥大学商学院&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.chicagogsb.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">multimedia</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcast<br></span><span style="COLOR: #008080">79</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>波士顿学院&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">frontrow.bc.edu<br></span><span style="COLOR: #008080">80</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>哈佛商学院在线&nbsp;<br></span><span style="COLOR: #008080">81</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.hbsp.harbard.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">b02</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">en</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">hbr_ideacast.jhtml;jsessioned</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NVHF0YFBS5ZCGAKRGWDR5VQBKE0YIISW<br></span><span style="COLOR: #008080">82</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>威斯康星麦迪逊大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">havenscenter.org</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">audio</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">audio.htm<br></span><span style="COLOR: #008080">83</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>约翰霍普金斯大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.johnshopkins.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcasts.index1.html<br></span><span style="COLOR: #008080">84</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>伦敦政治经济学院&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.lse.ac.uk</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">rescources</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcasts</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Default.htm<br></span><span style="COLOR: #008080">85</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>普林斯顿大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">uc.princeton.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">main</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.php<br></span><span style="COLOR: #008080">86</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>英国泰晤士报MBA&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">uc.princeton.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">main</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">index.php<br></span><span style="COLOR: #008080">87</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>耶鲁大学&nbsp;http:</span><span style="COLOR: #000000">//</span><span style="COLOR: #000000">www.yale.edu</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">opa</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">podcast</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">&nbsp;<br></span><span style="COLOR: #008080">88</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<img src ="http://www.cnitblog.com/houcy/aggbug/55491.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-03-17 14:50 <a href="http://www.cnitblog.com/houcy/archive/2009/03/17/55491.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转帖】freewrap——将tcl/tk脚本转变为可执行文件</title><link>http://www.cnitblog.com/houcy/archive/2009/01/01/53341.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Thu, 01 Jan 2009 14:36:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2009/01/01/53341.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/53341.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2009/01/01/53341.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/53341.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/53341.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FreeWrap可以把TCL/TK的脚本和二进制文件打包成应用程序，FreeWrap将所有的文件组合成一个单独的可执行文件。
<div>&nbsp;&nbsp;&nbsp;&nbsp;FreeWrap的原理是把脚本和tcl/tk解释器和库文件都打包在一个文件当中，做成一个可执行程序。生成的可执行文件实际上是一个压缩包，里面包含有需要使用的所有内容。不同的版本对应不同的tcl/tk版本，由于原始的tcl/tk版本只包括一些基本的库，所以如果需要使用更多的库，需要额外添加到文件中，还需要注意添加的方法和调用的顺序，如果是二进制的库就更麻烦了，需要额外的添加一段脚本。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;FreeWrap的可执行程序本身就是一个shell，如果修改了可执行程序的名字，在windows下把freeWrap修改为shell，再运行则是一个tcl/tk的shell。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;FreeWrap使用非常方便，就是一条命令，语法参考如下。</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;语法：freewrap dir/test.tcl [-debug] [-f FileLoadList] [-forcewrap] [-i ICOfile] [-o OutFile][-p] [-w WrapStub] File1 ... FileN</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;参数：</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;dir/test.tcl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCL/TK脚本主文件目录</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;File1 ... FileN&nbsp;&nbsp;&nbsp;需要打包在可执行程序里面的文件，用空格间隔</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-debug&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在打包的时候打开一个可以查看调试信息的窗口</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;需要打包的在命令后面的文件名详单</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-forcewrap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当freeWrap应用程序名被修改后，强制freeWrap程序以打包程序来运行</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指定生成的可执行应用程序的图标</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指定生成的可执行应用程序的名称</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创建一个freeWrap格式的程序包而不是创建一个可执行程序</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-w&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;生成跨平台的可执行文件</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;参数详解：</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;dir/test.tcl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;TCL/TK脚本主文件目录，命令紧接着的默认为主脚本，其它的文件都为额外添加的文件。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;File1 ... FileN&nbsp;&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;可以是任意的文件，但是要注意在生成的可执行程序包中的访问方式。比如你在命令中添加的file路径为C:\myfile\lib.tcl，那么在在打包程序中的目录结构是如下:</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\myfile\lib.tcl</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.tcl</div>
<div>所以在添加库文件时要十分小心，要保证在脚本中调用的文件为source \myfile\lib.tcl而不是source lib.tcl。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;可以罗列需要打包的文件路径名到一个txt文件当中，运行命令后自动添加，避免命令过长。比如有3个文件C:\lib1.tcl、C:\lib2.tcl和D:\lib3.tcl，那么就可以在一个txt文件中写入上面的全路径，注意一个文件路径名占用一行。在调用的时候就可以正常添加所需的文件了。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-forcewrap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;简单点说就是默认的应用程序为freewrap，如果由于需要程序名称修改成了shell，那么就可以使用 freewrap dir/test.tcl -forcewrap来打包一个程序，如果没有-forcewrap则是调用一个shell。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-i</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;使用-i选项去指定生成的可执行程序使用的图标。比如freewrap test.tcl -i test.ico，ico文件需要满足一下三种条件之一：1、16*16 16位色 2、32*32 16位色 3、32*32 2位色，如果是其他ico文件格式，在生成可执行文件时还是会采用默认的图标。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-o</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;指定生成的可执行应用程序的名称，比如freewrap test.tcl -o my.exe，生成的可执行程序就是my.exe而不是test.exe。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;-w</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;生成跨平台的可执行文件，生成的时候需要有目标平台的freewarp，举例如下：</div>
<div>在windows下生成可以在linux下运行的打包应用程序：freewrap test.tcl -w freewrap</div>
<div>在linux下生成可以在windows下运行的打包应用程序：freewrap test.tcl -w freewrap.exe</div>
<div>如果需要freewrap，可以在<a href="http://sourceforge.net/"><u><font color=#0000ff>http://sourceforge.net/</font></u></a>中找到，目前的最新版本为6.4，支持tcl/tk8.5.0</div>
<div>本文出自：<a href="http://blog.csdn.net/dulixin/archive/2008/02/26/2121569.aspx">http://blog.csdn.net/dulixin/archive/2008/02/26/2121569.aspx</a></div>
<img src ="http://www.cnitblog.com/houcy/aggbug/53341.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2009-01-01 22:36 <a href="http://www.cnitblog.com/houcy/archive/2009/01/01/53341.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ksh（1）</title><link>http://www.cnitblog.com/houcy/archive/2008/12/08/52356.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Mon, 08 Dec 2008 11:05:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2008/12/08/52356.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/52356.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2008/12/08/52356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/52356.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/52356.html</trackback:ping><description><![CDATA[ksh脚本语法总结（1）<br><br>1.&nbsp; [[ ...]]&nbsp;&nbsp; 用于字符串、文件属性、命令或函数调用、其它测试<br><br>如：<br>if [[ -n $str ]]<br><br><br>2. (( ... ))&nbsp; 用于对关系表达式求值<br><br>如：<br>if (( $1 &gt; $2 ))<br><br>3. $(...)&nbsp; 用于执行命令<br><br>如：<br>for dir&nbsp;in $(ls -l | grep "^d")<br><br>4. $((...)) 用于对算术表达式求值<br><br>如：<br>z=$((x+y))<br><br>5.${...} 用于对变量求值<br><br>如：<br>echo ${str}<br>echo ${1:?"input error"}<br><br>6. let 该命令用于对整数变量赋值<br><br>如：<br>while (($count &gt;0))<br>do&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; echo ${count}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let count=count-1<br>done<br><br>
<img src ="http://www.cnitblog.com/houcy/aggbug/52356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2008-12-08 19:05 <a href="http://www.cnitblog.com/houcy/archive/2008/12/08/52356.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL数据库中文读写问题</title><link>http://www.cnitblog.com/houcy/archive/2008/04/21/42600.html</link><dc:creator>挑灯看剑</dc:creator><author>挑灯看剑</author><pubDate>Mon, 21 Apr 2008 15:54:00 GMT</pubDate><guid>http://www.cnitblog.com/houcy/archive/2008/04/21/42600.html</guid><wfw:comment>http://www.cnitblog.com/houcy/comments/42600.html</wfw:comment><comments>http://www.cnitblog.com/houcy/archive/2008/04/21/42600.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/houcy/comments/commentRss/42600.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/houcy/services/trackbacks/42600.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 这两天写论文搭建运行环境，数据库用的MySQL，但是中文问题让我郁闷了一会，不断地百度，终于试验成功了。<br>&nbsp;&nbsp;&nbsp;&nbsp; MySQL默认的字符集是latin1，也就是ISO-8859，若要读写中文，需要设定为utf8格式。<br><br>【错误复现】<br>1.建立数据库和表：<br>新建库testdb:<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1&nbsp;&nbsp; mysql&gt; create database testdb;<br></span><font color=#008080>2</font><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">use</span><span style="COLOR: #000000">&nbsp;testdb;<br></span><span style="COLOR: #000000"><font color=#008080>3</font><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">Database</span><span style="COLOR: #000000">&nbsp;changed</span></div>
建表：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;tbl_user&nbsp;(name&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">20</span><span style="COLOR: #000000">));<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Query&nbsp;OK,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">&nbsp;rows&nbsp;affected&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0.14</span><span style="COLOR: #000000">&nbsp;sec)</span></div>
写中文时出现如下错误：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">insert</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">into</span><span style="COLOR: #000000">&nbsp;tbl_user&nbsp;</span><span style="COLOR: #0000ff">values</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">侯</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>ERROR&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1366</span><span style="COLOR: #000000">&nbsp;(HY000):&nbsp;Incorrect&nbsp;string&nbsp;value:&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">\xBA\xEE</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">column</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">&nbsp;at&nbsp;row&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span></div>
2.查看系统字符集<br>mysql&gt; show variables;<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&nbsp;character_set_client&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_connection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">binary</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_results&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_server&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_system&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8</span></div>
此时系统是utf8的字符集，因为我在安装mysql数据库时指定了字符集是utf8。<br>虽然数据库字符集已经是utf8了，但是无法往表中写中文，写入后成了乱码，读出的也是乱码。<br>3.用Java Bean读取数据库<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">java.sql.DriverManager.getConnection("jdbc:mysql:</span><span style="COLOR: #808080">//</span><span style="COLOR: #000000">localhost:</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3306</span><span style="COLOR: #808080">/</span><span style="COLOR: #000000">cr_db","root","</span><span style="FONT-WEIGHT: bold; COLOR: #800000">123456</span><span style="COLOR: #000000">");</span></div>
没有指定读取的字符方式useUnicode=true&amp;characterEncoding=utf-8<br>此时，用java bean读出的是乱码。<br>4.JSP页面读写中文也是乱码，jsp页面编码为gb2312：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;%</span><span style="COLOR: #000000">@&nbsp;page&nbsp;contentType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">text/html;&nbsp;charset=gb2312</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;language</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">java.sql.*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;errorPage</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">%&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
页面保持格式为普通的ANSI<br><br>【解决办法】<br>1.设定表的names为gbk字符<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">set</span><span style="COLOR: #000000">&nbsp;names&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">gbk</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Query&nbsp;OK,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">&nbsp;rows&nbsp;affected&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0.00</span><span style="COLOR: #000000">&nbsp;sec)</span></div>
2.系统字符集查看（保持utf8不变）<br>mysql&gt; show variables;<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&nbsp;character_set_client&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_connection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">binary</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_results&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_server&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8<br></span><span style="COLOR: #008080">7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;character_set_system&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;utf8</span></div>
3.Java Bean连接数据库方式修改为utf8：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">java.sql.DriverManager.getConnection("jdbc:mysql:</span><span style="COLOR: #808080">//</span><span style="COLOR: #000000">localhost:</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3306</span><span style="COLOR: #808080">/</span><span style="COLOR: #000000">cr_db?useUnicode=true&amp;characterEncoding=utf-8","root","</span><span style="FONT-WEIGHT: bold; COLOR: #800000">123456</span><span style="COLOR: #000000">");</span></div>
4.JSP页面中保持gb2312不变，但是在jsp页面中获取的界面输入要转化一下字符编码：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">&lt;%!</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img id=Codehighlighter1_44_241_Open_Image onclick="this.style.display='none'; Codehighlighter1_44_241_Open_Text.style.display='none'; Codehighlighter1_44_241_Closed_Image.style.display='inline'; Codehighlighter1_44_241_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_44_241_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_44_241_Closed_Text.style.display='none'; Codehighlighter1_44_241_Open_Image.style.display='inline'; Codehighlighter1_44_241_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;String&nbsp;convertCharSet(String&nbsp;str)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span id=Codehighlighter1_44_241_Open_Text><span style="COLOR: #000000">{&nbsp;<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img id=Codehighlighter1_53_177_Open_Image onclick="this.style.display='none'; Codehighlighter1_53_177_Open_Text.style.display='none'; Codehighlighter1_53_177_Closed_Image.style.display='inline'; Codehighlighter1_53_177_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_53_177_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_53_177_Closed_Text.style.display='none'; Codehighlighter1_53_177_Open_Image.style.display='inline'; Codehighlighter1_53_177_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</span><span id=Codehighlighter1_53_177_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;<br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;temp_p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">str;&nbsp;<br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">byte</span><span style="COLOR: #000000">[]&nbsp;temp_t</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">temp_p.getBytes(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ISO8859-1</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);&nbsp;<br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;temp</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;String(temp_t);&nbsp;<br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;temp;<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(Exception&nbsp;e)<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img id=Codehighlighter1_198_225_Open_Image onclick="this.style.display='none'; Codehighlighter1_198_225_Open_Text.style.display='none'; Codehighlighter1_198_225_Closed_Image.style.display='inline'; Codehighlighter1_198_225_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_198_225_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_198_225_Closed_Text.style.display='none'; Codehighlighter1_198_225_Open_Image.style.display='inline'; Codehighlighter1_198_225_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</span><span id=Codehighlighter1_198_225_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">%&gt;</span></div>
写库时先转化再执行sql命令：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">sqlStr</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">convertCharSet(sqlStr);<br></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>sqlBean.executeUpdate(sqlStr);</span></div>
<br><br>【效果】<br>1.直接命令行下读写中文：<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">&nbsp;1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">insert</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">into</span><span style="COLOR: #000000">&nbsp;tbl_user&nbsp;</span><span style="COLOR: #0000ff">values</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">侯</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">&nbsp;2</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>Query&nbsp;OK,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">&nbsp;row&nbsp;affected&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0.08</span><span style="COLOR: #000000">&nbsp;sec)<br></span><span style="COLOR: #008080">&nbsp;3</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>mysql</span><span style="COLOR: #808080">&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">*</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;tbl_user;<br></span><span style="COLOR: #008080">&nbsp;4</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">+</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">-----+</span><span style="COLOR: #008080"><br></span><span style="COLOR: #008080">&nbsp;5</span><span style="COLOR: #008080"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;name&nbsp;&nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;6</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">+</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">-----+</span><span style="COLOR: #008080"><br></span><span style="COLOR: #008080">&nbsp;7</span><span style="COLOR: #008080"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;houcy&nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;8</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">|</span><span style="COLOR: #000000">&nbsp;侯&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span><span style="COLOR: #808080">|</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">&nbsp;9</span><span style="COLOR: #000000"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #808080">+</span><span style="COLOR: #008080">--</span><span style="COLOR: #008080">-----+</span><span style="COLOR: #008080"><br></span><span style="COLOR: #008080">10</span><span style="COLOR: #008080"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="FONT-WEIGHT: bold; COLOR: #800000">2</span><span style="COLOR: #000000">&nbsp;rows&nbsp;</span><span style="COLOR: #808080">in</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">set</span><span style="COLOR: #000000">&nbsp;(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0.03</span><span style="COLOR: #000000">&nbsp;sec)</span></div>
<p>2.用Java Bean读写中文也能成功！<br><br>哈哈，已经成功写入中文啦！o(&#8745;_&#8745;)o...<br><br>【总结】<br>1.数据库字符集需设定为utf8格式<br>可以在安装mysql时指定，也可以在建立数据库时指定整个库的字符集：<br>如：</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">DATABASE</span><span style="COLOR: #000000">&nbsp;cr_db&nbsp;&nbsp;</span><span style="COLOR: #0000ff">DEFAULT</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">CHARACTER</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;utf8&nbsp;</span><span style="COLOR: #0000ff">default</span><span style="COLOR: #000000">&nbsp;collate&nbsp;utf8_general_ci;</span></div>
<p>这样整个cr_db库中的每个均是utf8字符集了。<br>2.设定names为gbk <br>3.连接数据库时指定连接方式useUnicode=true&amp;characterEncoding=utf-8<br><br><br><br><br><br></p>
<img src ="http://www.cnitblog.com/houcy/aggbug/42600.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/houcy/" target="_blank">挑灯看剑</a> 2008-04-21 23:54 <a href="http://www.cnitblog.com/houcy/archive/2008/04/21/42600.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>