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

<channel>
	<title>瀚海星空</title>
	<atom:link href="http://abloz.com/feed" rel="self" type="application/rss+xml" />
	<link>http://abloz.com</link>
	<description>星空有烂，观之忘我</description>
	<lastBuildDate>Tue, 14 Feb 2012 21:04:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>博客的广告</title>
		<link>http://abloz.com/2012/02/15/bo-ke-di-guang-gao.html</link>
		<comments>http://abloz.com/2012/02/15/bo-ke-di-guang-gao.html#comments</comments>
		<pubDate>Tue, 14 Feb 2012 21:04:19 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[杂项]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1497</guid>
		<description><![CDATA[<p><!--/* OpenX Javascript Tag v2.8.8 */--></p>
<p><!--/*<br />
  * The backup image section of this tag has been generated for use on a<br />
  * non-SSL page. If this tag is to be placed on an SSL page, change the<br />
  *   'http://darwincare.com/www/delivery/...'<br />
  * to<br />
  *   'https://darwincare.com/www/delivery/...'<br />
  *<br />
  * This noscript section of this tag only shows image banners. There<br />
  * is no width or height in these banners, so if you want these tags to<br />
  * allocate space for the ad before it shows, you will need to add this<br />
  * information to the <img> tag.<br />
  *<br />
  * If you do not want to deal with the intricities of the noscript<br />
  * section, delete the tag (from <noscript>&#8230; to </noscript>). On<br />
  * average, the noscript tag is called from less than 1% of internet<br />
  * users.<br />
  */&#8211;></p>
<p><script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://darwincare.com/www/delivery/ajs.php':'http://darwincare.com/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=13");
   document.write ('&#38;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&#38;exclude=" + document.MAX_used);
   document.write (document.charset ? '&#38;charset='+document.charset : (document.characterSet ? '&#38;charset='+document.characterSet : ''));
   document.write ("&#38;loc=" + escape(window.location));
   if (document.referrer) document.write ("&#38;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&#38;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&#62;--></script></p>


<p></p>


]]></description>
			<content:encoded><![CDATA[<p><!--/* OpenX Javascript Tag v2.8.8 */--></p>
<p><!--/*<br />
  * The backup image section of this tag has been generated for use on a<br />
  * non-SSL page. If this tag is to be placed on an SSL page, change the<br />
  *   'http://darwincare.com/www/delivery/...'<br />
  * to<br />
  *   'https://darwincare.com/www/delivery/...'<br />
  *<br />
  * This noscript section of this tag only shows image banners. There<br />
  * is no width or height in these banners, so if you want these tags to<br />
  * allocate space for the ad before it shows, you will need to add this<br />
  * information to the <img> tag.<br />
  *<br />
  * If you do not want to deal with the intricities of the noscript<br />
  * section, delete the tag (from <noscript>&#8230; to </noscript>). On<br />
  * average, the noscript tag is called from less than 1% of internet<br />
  * users.<br />
  */&#8211;></p>
<p><script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://darwincare.com/www/delivery/ajs.php':'http://darwincare.com/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=13");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&gt;--></script></p>


<p></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2012/02/15/bo-ke-di-guang-gao.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>联想乐pad</title>
		<link>http://abloz.com/2012/02/04/lenovo-music-pad.html</link>
		<comments>http://abloz.com/2012/02/04/lenovo-music-pad.html#comments</comments>
		<pubDate>Sat, 04 Feb 2012 12:54:09 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1490</guid>
		<description><![CDATA[<p>img方式<br />
<a href="http://124.207.177.202/www/delivery/ck.php?n=a6d047f4&#38;cb=INSERT_RANDOM_NUMBER_HERE" target="_blank"><img src="http://124.207.177.202/www/delivery/avw.php?zoneid=2&#38;cb=INSERT_RANDOM_NUMBER_HERE&#38;n=a6d047f4" alt="" border="0" /></a></p>
<p>乐pad联想 iframe<br />
<iframe id='a457c5f2' name='a457c5f2' src='http://124.207.177.202/www/delivery/afr.php?zoneid=2&#38;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='900' height='200'><a href='http://124.207.177.202/www/delivery/ck.php?n=aca14421&#38;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://124.207.177.202/www/delivery/avw.php?zoneid=2&#38;cb=INSERT_RANDOM_NUMBER_HERE&#38;n=aca14421' border='0' alt='' /></a></iframe></p>
<p>js:</p>
<p><script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://124.207.177.202/www/delivery/ajs.php':'http://124.207.177.202/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=2");
   document.write ('&#38;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&#38;exclude=" + document.MAX_used);
   document.write (document.charset ? '&#38;charset='+document.charset : (document.characterSet ? '&#38;charset='+document.characterSet : ''));
   document.write ("&#38;loc=" + escape(window.location));
   if (document.referrer) document.write ("&#38;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&#38;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&#62;--></script><noscript><a href='http://124.207.177.202/www/delivery/ck.php?n=a85190ee&#38;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://124.207.177.202/www/delivery/avw.php?zoneid=2&#38;cb=INSERT_RANDOM_NUMBER_HERE&#38;n=a85190ee' border='0' alt='' /></a></noscript></p>


<p>相关博文：<ol><li><a href='http://abloz.com/2009/11/17/site-recruited.html' rel='bookmark' title='Permanent Link: 网站中招了？'>网站中招了？</a></li>
</ol></p>


相关博文：<ol><li><a href='http://abloz.com/2009/11/17/site-recruited.html' rel='bookmark' title='Permanent Link: 网站中招了？'>网站中招了？</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>img方式<br />
<a href="http://124.207.177.202/www/delivery/ck.php?n=a6d047f4&amp;cb=INSERT_RANDOM_NUMBER_HERE" target="_blank"><img src="http://124.207.177.202/www/delivery/avw.php?zoneid=2&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a6d047f4" alt="" border="0" /></a></p>
<p>乐pad联想 iframe<br />
<iframe id='a457c5f2' name='a457c5f2' src='http://124.207.177.202/www/delivery/afr.php?zoneid=2&amp;cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='900' height='200'><a href='http://124.207.177.202/www/delivery/ck.php?n=aca14421&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://124.207.177.202/www/delivery/avw.php?zoneid=2&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=aca14421' border='0' alt='' /></a></iframe></p>
<p>js:</p>
<p><script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://124.207.177.202/www/delivery/ajs.php':'http://124.207.177.202/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=2");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&gt;--></script><noscript><a href='http://124.207.177.202/www/delivery/ck.php?n=a85190ee&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://124.207.177.202/www/delivery/avw.php?zoneid=2&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a85190ee' border='0' alt='' /></a></noscript></p>


<p>相关博文：<ol><li><a href='http://abloz.com/2009/11/17/site-recruited.html' rel='bookmark' title='Permanent Link: 网站中招了？'>网站中招了？</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2012/02/04/lenovo-music-pad.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>广告</title>
		<link>http://abloz.com/2012/02/04/advertising.html</link>
		<comments>http://abloz.com/2012/02/04/advertising.html#comments</comments>
		<pubDate>Sat, 04 Feb 2012 12:49:24 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1487</guid>
		<description><![CDATA[<p>广告<br />
<script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://124.207.177.202/www/delivery/ajs.php':'http://124.207.177.202/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=1");
   document.write ('&#38;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&#38;exclude=" + document.MAX_used);
   document.write (document.charset ? '&#38;charset='+document.charset : (document.characterSet ? '&#38;charset='+document.characterSet : ''));
   document.write ("&#38;loc=" + escape(window.location));
   if (document.referrer) document.write ("&#38;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&#38;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&#62;--></script></p>


<p></p>


]]></description>
			<content:encoded><![CDATA[<p>广告<br />
<script type='text/javascript'><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://124.207.177.202/www/delivery/ajs.php':'http://124.207.177.202/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=1");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&#038;context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]&gt;--></script></p>


<p></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2012/02/04/advertising.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php 网站点击生成csv文件，解决乱码问题</title>
		<link>http://abloz.com/2012/01/10/csv-file-php-generate-website-hits-solve-the-garbage-problem.html</link>
		<comments>http://abloz.com/2012/01/10/csv-file-php-generate-website-hits-solve-the-garbage-problem.html#comments</comments>
		<pubDate>Tue, 10 Jan 2012 07:49:27 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[中文]]></category>
		<category><![CDATA[乱码]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1484</guid>
		<description><![CDATA[abloz.com
周海汉 2012.1.10
先上一首诗：
锄禾日当午，春运订票苦 。
95105，一拨一上午。
拨了一上午，车票还没谱。
过年回不回，心里很痛苦。
为何会这样，只能问政府。          
  作者：白交易
庆贺多路出击终于买到了2012春运火车票，虽然是硬坐票，多年未挤火车[......]<p class='read-more'><a href='http://abloz.com/2012/01/10/csv-file-php-generate-website-hits-solve-the-garbage-problem.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2011/10/13/php-sheng-cheng-xml-di-wen-ti.html' rel='bookmark' title='Permanent Link: php 生成xml的问题'>php 生成xml的问题</a></li>
<li><a href='http://abloz.com/2008/03/01/e2-80-9c-e8-89-b3-e7-85-a7-e9-97-a8-e2-80-9d-e8-bf-87-e5-90-8e-ef-bc-8c-e6-8d-a2-e6-8d-a2-e5-8f-a3-e5-91-b3.html' rel='bookmark' title='Permanent Link: “艳照门”过后，换换口味'>“艳照门”过后，换换口味</a></li>
<li><a href='http://abloz.com/2011/08/25/php-drawing-the-generated-identification-number-of-chinese.html' rel='bookmark' title='Permanent Link: php 画图，生成中文的识别码'>php 画图，生成中文的识别码</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>abloz.com</p>
<p>周海汉 2012.1.10</p>
<p>先上一首诗：</p>
<p>锄禾日当午，春运订票苦 。<br />
95105，一拨一上午。<br />
拨了一上午，车票还没谱。<br />
过年回不回，心里很痛苦。<br />
为何会这样，只能问政府。          <br />
  作者：白交易</p>
<p>庆贺多路出击终于买到了2012春运火车票，虽然是硬坐票，多年未挤火车了，这次要甩开膀子干了：)</p>
<p>php点击，从数据库生成csv格式的文件供下载，有两个问题：</p>
<p>1.中文文件名，在不同的浏览器下可能出现乱码</p>
<p>2.内容的乱码问题</p>
<p>重要建议，对部署在linux上，采用utf8编码的数据库和php文件，直接将内容转为gbk，可以用mb_convert_encoding或者iconv，这样省很多麻烦。不要转为utf16le格式的csv，否则还是容易遇到问题。utf8格式的csv有吗？没有。所以在windows上的csv格式，只有用gbk内容最简单。</p>
<p>有一个fputcsv函数，可以将array转成以逗号分隔的内容。header()函数可以让浏览器生成可以下载的csv文件。</p>
<pre><span style="font-family: Courier New;">    function query_to_csv($query, $filename="", $attachment = true, $headers = true)
    {
     if( empty( $filename ) )
  {
   $filename = "abloz_com_".date("Ymd").".csv";
  }
     header('Cache-control: private');
       
   
        if($attachment) {
            // send response headers to the browser
      //判断浏览器，输出双字节文件名不乱码
      $encoded_filename  = urlencode($filename);
         $encoded_filename  = str_replace("+","%20",$encoded_filename );
         
            $fp = fopen('php://output', 'w');
         $ua = $_SERVER["HTTP_USER_AGENT"];
      if (preg_match("/MSIE/", $ua)) {
          header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
      }
      else if (preg_match("/Firefox/", $ua)) {
          header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');
      }
      else {
          header('Content-Disposition: attachment; filename="' . $filename . '"');
      }
      //if(function_exists('mb_convert_encoding')){
          //header('Content-type: text/csv; charset=UTF-16LE');
         header( 'Content-Type: text/csv' );
<span style="font-family: Courier New;">  } else {
            $fp = fopen($filename, 'w');
        }
        $result = mysql_query($query, $this-&gt;conn) or die( mysql_error( $this-&gt;conn ) );
       
        if($headers) {
            // output header row (if at least one row exists)
            $row = mysql_fetch_assoc($result);
            if($row) {
             $row = array_map("utf8togbk",array_keys($row));
                fputcsv($fp,$row );//,mb_convert_encoding(',',"UTF-16LE","UTF-8")
                // reset pointer back to beginning
                mysql_data_seek($result, 0);
            }
        }
       
        while($row = mysql_fetch_assoc($result)) {
         $row = array_map("utf8togbk",$row);
         
            fputcsv($fp, $row);//,mb_convert_encoding(',',"UTF-16LE","UTF-8")
        }
       
        fclose($fp);
    }
<span style="font-family: Courier New;">function utf8togbk($elem)
{
 return mb_convert_encoding($elem,"GBK","UTF-8");//"auto" = "ASCII,JIS,UTF-8,EUC-JP,SJIS".
}</span></span></span></pre>
<p>如果转为utf16-le格式，还要写bom，而且就算内容转成功，fputcsv函数生成的分隔符“,”还是ansi的，打开还是乱码。除非自己写一个直接生成csv格式的函数。</p>
<p>为了防止麻烦，就用utf8格式了。</p>
<p>对于下载时文件名乱码问题，根据浏览器，提供不同的header，进行解决：</p>
<pre><span style="font-family: Courier New;">      //判断浏览器，输出双字节文件名不乱码
      $encoded_filename  = urlencode($filename);
         $encoded_filename  = str_replace("+","%20",$encoded_filename );
         
            $fp = fopen('php://output', 'w');
         $ua = $_SERVER["HTTP_USER_AGENT"];
      if (preg_match("/MSIE/", $ua)) {
          header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
      }
      else if (preg_match("/Firefox/", $ua)) {
          header('Content-Disposition: attachment; filename*="utf8\'\'' . $filename . '"');
      }
      else {
          header('Content-Disposition: attachment; filename="' . $filename . '"');
      }
</span></pre>
<p>对ie和firefox进行特殊处理。</p>
<p>query_to_csv是一个db类的成员函数，所以connection直接用了成员变量。如果是独立函数，可以将conn做成全局或参数传入。</p>
<p>用法：</p>
<pre><span style="font-family: Courier New;">    require_once 'mydb_code.php';
    $db = new mydb();</span></pre>
<pre><span style="font-family: Courier New;">    $sql = "SELECT * FROM users";
    </span><span style="font-family: Courier New;">// output as a csv attachment
    $db-&gt;query_to_csv($sql, "周海汉.csv");</span></pre>
<p>&nbsp;</p>


<p>相关博文：<ol><li><a href='http://abloz.com/2011/10/13/php-sheng-cheng-xml-di-wen-ti.html' rel='bookmark' title='Permanent Link: php 生成xml的问题'>php 生成xml的问题</a></li>
<li><a href='http://abloz.com/2008/03/01/e2-80-9c-e8-89-b3-e7-85-a7-e9-97-a8-e2-80-9d-e8-bf-87-e5-90-8e-ef-bc-8c-e6-8d-a2-e6-8d-a2-e5-8f-a3-e5-91-b3.html' rel='bookmark' title='Permanent Link: “艳照门”过后，换换口味'>“艳照门”过后，换换口味</a></li>
<li><a href='http://abloz.com/2011/08/25/php-drawing-the-generated-identification-number-of-chinese.html' rel='bookmark' title='Permanent Link: php 画图，生成中文的识别码'>php 画图，生成中文的识别码</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2012/01/10/csv-file-php-generate-website-hits-solve-the-garbage-problem.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>python 如何 打印负数为16进制 无符号数？</title>
		<link>http://abloz.com/2011/12/30/python-how-to-print-a-negative-number-as-an-unsigned-hexadecimal-number.html</link>
		<comments>http://abloz.com/2011/12/30/python-how-to-print-a-negative-number-as-an-unsigned-hexadecimal-number.html#comments</comments>
		<pubDate>Fri, 30 Dec 2011 09:18:29 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[杂感]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[负数]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1481</guid>
		<description><![CDATA[如，想将-1打印成0xffffffff，结果是：
&#62;&#62;&#62; a=-1
&#62;&#62;&#62; hex(a)
'-0x1'
&#62;&#62;&#62; print "%u"%a
-1
&#62;&#62;&#62; print "%x"%a
-1
&#62;&#62;&#62; print hex[......]<p class='read-more'><a href='http://abloz.com/2011/12/30/python-how-to-print-a-negative-number-as-an-unsigned-hexadecimal-number.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html' rel='bookmark' title='Permanent Link: python 实现和 C的IP socket通信如何打包数据？'>python 实现和 C的IP socket通信如何打包数据？</a></li>
<li><a href='http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html' rel='bookmark' title='Permanent Link: python google protobuf 使用'>python google protobuf 使用</a></li>
<li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>如，想将-1打印成0xffffffff，结果是：</p>
<pre>&gt;&gt;&gt; a=-1
&gt;&gt;&gt; hex(a)
'-0x1'
&gt;&gt;&gt; print "%u"%a
-1
&gt;&gt;&gt; print "%x"%a
-1
&gt;&gt;&gt; print hex(a)
-0x1</pre>
<p>&nbsp;</p>
<p>没有办法将其打印成0xffffffff。打印和转化办法，可以定义hex2函数进行转换：</p>
<pre></pre>
<pre>&gt;&gt;&gt; print hex(a&amp;0xffffffff)
0xffffffffL
&gt;&gt;&gt; b=-2
&gt;&gt;&gt; print "0x%08x"%(b&amp;0xffffffff)
0xfffffffe

&gt;&gt;&gt; def hex2(a):
...     return a&gt;0 and hex(a) or hex(a&amp;0xffffffff)
...
&gt;&gt;&gt; hex2(a)
'0xffffffffL'
&gt;&gt;&gt; hex2(234)
'0xea'
&gt;&gt;&gt; hex2(b)
'0xfffffffeL'</pre>


<p>相关博文：<ol><li><a href='http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html' rel='bookmark' title='Permanent Link: python 实现和 C的IP socket通信如何打包数据？'>python 实现和 C的IP socket通信如何打包数据？</a></li>
<li><a href='http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html' rel='bookmark' title='Permanent Link: python google protobuf 使用'>python google protobuf 使用</a></li>
<li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/12/30/python-how-to-print-a-negative-number-as-an-unsigned-hexadecimal-number.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>hadoop 1.0发布</title>
		<link>http://abloz.com/2011/12/30/hadoop-1-0-release.html</link>
		<comments>http://abloz.com/2011/12/30/hadoop-1-0-release.html#comments</comments>
		<pubDate>Fri, 30 Dec 2011 05:42:41 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[hadoop]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1478</guid>
		<description><![CDATA[<p>据apache hadoop官网消息，经过6年开发，2011.12.27日，hadoop发布1.0版本。</p>
<p>这是<a href="http://hadoop.apache.org/common/docs/r1.0.0/releasenotes.html">release notes</a>。本次发布改进了安全，hbase，webhdfs，性能等。</p>


<p></p>


]]></description>
			<content:encoded><![CDATA[<p>据apache hadoop官网消息，经过6年开发，2011.12.27日，hadoop发布1.0版本。</p>
<p>这是<a href="http://hadoop.apache.org/common/docs/r1.0.0/releasenotes.html">release notes</a>。本次发布改进了安全，hbase，webhdfs，性能等。</p>


<p></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/12/30/hadoop-1-0-release.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache alias 目录配置</title>
		<link>http://abloz.com/2011/12/29/apache-alias-directory-configuration.html</link>
		<comments>http://abloz.com/2011/12/29/apache-alias-directory-configuration.html#comments</comments>
		<pubDate>Thu, 29 Dec 2011 05:50:07 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1475</guid>
		<description><![CDATA[一个apache网站，在不同目录下有不同网站，但在同一个域名下，这时可以配置alias，这与多域名不一样。
在http.conf里增加：
Alias /fb  d:/myphp/fb/  

&#60;Directory "d:/myphp/fb/"&#62;
    Options Indexes F[......]<p class='read-more'><a href='http://abloz.com/2011/12/29/apache-alias-directory-configuration.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2009/06/03/apache-web-directory-access-denied-transfer-solution.html' rel='bookmark' title='Permanent Link: apache移web目录后拒绝访问解决办法'>apache移web目录后拒绝访问解决办法</a></li>
<li><a href='http://abloz.com/2010/04/21/transfer-comparative-analysis-of-three-web-server-apache-lighttpd-nginx.html' rel='bookmark' title='Permanent Link: ［转］三大WEB服务器对比分析（apache ,lighttpd,nginx'>［转］三大WEB服务器对比分析（apache ,lighttpd,nginx</a></li>
<li><a href='http://abloz.com/2010/04/14/firefox-dns-resolution-is-very-slow.html' rel='bookmark' title='Permanent Link: firefox dns解析很慢？'>firefox dns解析很慢？</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>一个apache网站，在不同目录下有不同网站，但在同一个域名下，这时可以配置alias，这与多域名不一样。</p>
<p>在http.conf里增加：</p>
<pre>Alias /fb  d:/myphp/fb/  

&lt;Directory "d:/myphp/fb/"&gt;
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
&lt;/Directory&gt;</pre>


<p>相关博文：<ol><li><a href='http://abloz.com/2009/06/03/apache-web-directory-access-denied-transfer-solution.html' rel='bookmark' title='Permanent Link: apache移web目录后拒绝访问解决办法'>apache移web目录后拒绝访问解决办法</a></li>
<li><a href='http://abloz.com/2010/04/21/transfer-comparative-analysis-of-three-web-server-apache-lighttpd-nginx.html' rel='bookmark' title='Permanent Link: ［转］三大WEB服务器对比分析（apache ,lighttpd,nginx'>［转］三大WEB服务器对比分析（apache ,lighttpd,nginx</a></li>
<li><a href='http://abloz.com/2010/04/14/firefox-dns-resolution-is-very-slow.html' rel='bookmark' title='Permanent Link: firefox dns解析很慢？'>firefox dns解析很慢？</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/12/29/apache-alias-directory-configuration.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python google protobuf 使用</title>
		<link>http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html</link>
		<comments>http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html#comments</comments>
		<pubDate>Wed, 28 Dec 2011 12:47:26 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[protobuf]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1473</guid>
		<description><![CDATA[google protobuf由于采用二进制打包，数据量很小，又支持主流的java,c,python语言，所以尤其适合于mobile客户端与服务器的通信。相对于xml，html，json等格式，有其独特优势。
下载：<a href="http://code.google.com/p/protobuf/downloads/list">http://code.google.com/p/protobuf/download[......]</a><p class='read-more'><a href='http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
<li><a href='http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html' rel='bookmark' title='Permanent Link: python 实现和 C的IP socket通信如何打包数据？'>python 实现和 C的IP socket通信如何打包数据？</a></li>
<li><a href='http://abloz.com/2008/05/21/regularly-back-up-files-using-python-script.html' rel='bookmark' title='Permanent Link: 用python脚本定期备份文件'>用python脚本定期备份文件</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>google protobuf由于采用二进制打包，数据量很小，又支持主流的java,c,python语言，所以尤其适合于mobile客户端与服务器的通信。相对于xml，html，json等格式，有其独特优势。</p>
<p>下载：<a href="http://code.google.com/p/protobuf/downloads/list">http://code.google.com/p/protobuf/downloads/list</a></p>
<p>解压后里面有个python目录。linux可以直接编译源码，对windows，可以将protoc.exe拷贝到python目录下，然后在cmd下，切换到该目录，执行python setup.py install</p>
<p>&nbsp;</p>
<p>然后就可以用命令将proto文件编译成py：</p>
<p>protoc.exe &#8211;python_out=d:/test/ *.proto</p>
<p>&nbsp;</p>
<p>示例：</p>
<p>完成测试test.proto</p>
<pre>message TestMsg
{
    required int32 id=1;
    required int32 time=2;
    optional string note=3;
}</pre>
<p>protoc.exe &#8211;python_out=d:/test/ test.proto</p>
<pre>#-*- coding:utf-8 -*-
import google.protobuf
import TestMsg_pb2
import time

#压缩
test = TestMsg_pb2()
test.id=1
test.time=int(time.time())
test.string="asdftest"
print test
test_str = test.SerializeToString()
print test_str
#解压
test1 = TestMsg_pb2()
test1.ParseFromString(test_str)
print test1</pre>


<p>相关博文：<ol><li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
<li><a href='http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html' rel='bookmark' title='Permanent Link: python 实现和 C的IP socket通信如何打包数据？'>python 实现和 C的IP socket通信如何打包数据？</a></li>
<li><a href='http://abloz.com/2008/05/21/regularly-back-up-files-using-python-script.html' rel='bookmark' title='Permanent Link: 用python脚本定期备份文件'>用python脚本定期备份文件</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/12/28/python-google-protobuf-shi-yong.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python 实现和 C的IP socket通信如何打包数据？</title>
		<link>http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html</link>
		<comments>http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html#comments</comments>
		<pubDate>Wed, 28 Dec 2011 12:21:06 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[struct]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1469</guid>
		<description><![CDATA[服务器端是C/C++写的，python用于客户端发送消息，进行通信。这种模式可以用于压力测试，方便修改协议。
<strong>问题：</strong>
1.python 对于组包和二进制的操作没有C语言那么方便，如何针对数据类型打包？
python作为方便的脚本语言，提供了很少的几种数据类型，和C语言不能一一对应。打通信包时，不能做[......]<p class='read-more'><a href='http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2011/09/07/c-language-the-url-to-the-code-submit-content-to-the-site.html' rel='bookmark' title='Permanent Link: C语言的url转码，提交内容到网站'>C语言的url转码，提交内容到网站</a></li>
<li><a href='http://abloz.com/2010/12/15/sizeof-32-bit-and-64-bit-compatibility.html' rel='bookmark' title='Permanent Link: sizeof的32位和64位兼容问题'>sizeof的32位和64位兼容问题</a></li>
<li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>服务器端是C/C++写的，python用于客户端发送消息，进行通信。这种模式可以用于压力测试，方便修改协议。</p>
<p><strong>问题：</strong></p>
<p>1.python 对于组包和二进制的操作没有C语言那么方便，如何针对数据类型打包？</p>
<p>python作为方便的脚本语言，提供了很少的几种数据类型，和C语言不能一一对应。打通信包时，不能做到像C语言那样移动和操作指针。</p>
<p>2.对于变长的字符串变量如何打到python包中</p>
<p>struct中格式化字符串需指定长度，但如果字符串长度不是固定的，如何打包和解包呢？</p>
<p>解决办法： 用python 的struct来进行打包。struct提供pack,unpack,pack_into,unpack_from函数，提供与C语言对应的数据format。</p>
<p>3.二进制数据如何打包？</p>
<p>&nbsp;</p>
<p><strong>1. 格式化二进制数据</strong></p>
<p>示例：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">struct</span>
fmt=<span style="color: #483d8b;">&quot;ii&quot;</span>
buf = <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span>fmt,<span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">repr</span><span style="color: black;">&#40;</span>buf<span style="color: black;">&#41;</span></pre></div></div>

<p>会将两个整形以二进制打到包中。程序执行结果：</p>
<pre>'\x01\x00\x00\x00\x02\x00\x00\x00'</pre>
<p>格式和C语言类型的对应关系：</p>
<table border="1">
<colgroup>
<col width="10%" />
<col width="31%" />
<col width="25%" />
<col width="20%" />
<col width="15%" /></colgroup>
<thead valign="bottom">
<tr>
<th>Format</th>
<th>C Type</th>
<th>Python type</th>
<th>Standard size</th>
<th>Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td><tt>x</tt></td>
<td>pad byte</td>
<td>no value</td>
<td></td>
<td></td>
</tr>
<tr>
<td><tt>c</tt></td>
<td><tt>char</tt></td>
<td>string of length 1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td><tt>b</tt></td>
<td><tt>signed char</tt></td>
<td>integer</td>
<td>1</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>B</tt></td>
<td><tt>unsigned char</tt></td>
<td>integer</td>
<td>1</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>?</tt></td>
<td><tt>_Bool</tt></td>
<td>bool</td>
<td>1</td>
<td>(1)</td>
</tr>
<tr>
<td><tt>h</tt></td>
<td><tt>short</tt></td>
<td>integer</td>
<td>2</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>H</tt></td>
<td><tt>unsigned short</tt></td>
<td>integer</td>
<td>2</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>i</tt></td>
<td><tt>int</tt></td>
<td>integer</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>I</tt></td>
<td><tt>unsigned int</tt></td>
<td>integer</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>l</tt></td>
<td><tt>long</tt></td>
<td>integer</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>L</tt></td>
<td><tt>unsigned long</tt></td>
<td>integer</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td><tt>q</tt></td>
<td><tt>long long</tt></td>
<td>integer</td>
<td>8</td>
<td>(2), (3)</td>
</tr>
<tr>
<td><tt>Q</tt></td>
<td><tt>unsigned long long</tt></td>
<td>integer</td>
<td>8</td>
<td>(2), (3)</td>
</tr>
<tr>
<td><tt>f</tt></td>
<td><tt>float</tt></td>
<td>float</td>
<td>4</td>
<td>(4)</td>
</tr>
<tr>
<td><tt>d</tt></td>
<td><tt>double</tt></td>
<td>float</td>
<td>8</td>
<td>(4)</td>
</tr>
<tr>
<td><tt>s</tt></td>
<td><tt>char[]</tt></td>
<td>string</td>
<td></td>
<td></td>
</tr>
<tr>
<td><tt>p</tt></td>
<td><tt>char[]</tt></td>
<td>string</td>
<td></td>
<td></td>
</tr>
<tr>
<td><tt>P</tt></td>
<td><tt>void *</tt></td>
<td>integer</td>
<td></td>
<td>(5), (3)</td>
</tr>
</tbody>
</table>
<p>其中 p是pascal 类型的字符串，s是c语言类型字符串。format中可以增加一个长度描述。如”6i”表示6个整形。”20s”表示20个字节长度的字符串，而“20c”表示20个字节。format还可以指定字节序。</p>
<table border="1">
<colgroup>
<col width="20%" />
<col width="43%" />
<col width="18%" />
<col width="20%" /></colgroup>
<thead valign="bottom">
<tr>
<th>Character</th>
<th>Byte order</th>
<th>Size</th>
<th>Alignment</th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td><tt>@</tt></td>
<td>native</td>
<td>native</td>
<td>native</td>
</tr>
<tr>
<td><tt>=</tt></td>
<td>native</td>
<td>standard</td>
<td>none</td>
</tr>
<tr>
<td><tt>&lt;</tt></td>
<td>little-endian</td>
<td>standard</td>
<td>none</td>
</tr>
<tr>
<td><tt>&gt;</tt></td>
<td>big-endian</td>
<td>standard</td>
<td>none</td>
</tr>
<tr>
<td><tt>!</tt></td>
<td>network (= big-endian)</td>
<td>standard</td>
<td>none</td>
</tr>
</tbody>
</table>
<p>网络字节序一般用“!”打头。</p>
<p><strong>2.给字符串变量打包</strong></p>
<p>可以对格式化字符串再格式化，填写变量长度</p>
<p>示例</p>
<pre>&gt;&gt;&gt; a="test buf"
&gt;&gt;&gt; leng=len(a)
&gt;&gt;&gt; fmt="i%ds"%leng
&gt;&gt;&gt; buf=struct.pack(fmt,1,a)</pre>
<pre>&gt;&gt;&gt; print repr(buf)
'\x01\x00\x00\x00test buf'</pre>
<p>如果是单纯打包，stackoverflow给出一种方式，可以用于打变量字符串：</p>
<pre>#给字符串变量打包，给出长度
struct.pack("I%ds" % (len(s),), len(s), s)

#解包
def unpack_helper(self,fmt, data):
    size = struct.calcsize(fmt)
    return struct.unpack(fmt, data[:size]), data[size:]

fmt_head="!6i"
head,probuf = self.unpack_helper(fmt_head,buf)</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>3.打包二进制</strong></p>
<p>二进制包可以直接将二进制坠在格式化数据后面，可以用字符串的方式处理。</p>
<pre>&gt;&gt;&gt; fmt1="!i"
&gt;&gt;&gt; buf2=struct.pack(fmt1,2)+buf1
&gt;&gt;&gt; print repr(buf2)
'\x00\x00\x00\x02\x01\x00\x00\x00\x02\x00\x00\x00'</pre>
<p>&nbsp;</p>
<p><strong>4.实例 给一个二进制header后缀二进制数据</strong></p>
<p>suffix是后缀的二进制或字符串，leng 是header中用于描述后缀长度的变量，type是cmdtype</p>
<pre>def getheader(msgtype,leng,suffix):
    magic = 0
    sn=0
    ori_res=0
    # mtype=msgtype
    param = 0
    #mleng = leng

    fmt="!6i"
    buf = struct.pack(fmt,magic,sn,ori_res,msgtype,param,leng)+suffix</pre>
<p>&nbsp;</p>
<p>或者pack_into，可以pack到一个buf中</p>
<pre>def getheader(msgtype,leng,suffix):
    magic = 0
    sn=0
    ori_res=0
    # mtype=msgtype
    param = 0
    #mleng = leng

    buf = create_string_buffer(24+leng)

    fmt = "!6i%ds"%leng
    print fmt
    struct.pack_into(fmt,buf,0,magic,sn,ori_res,msgtype,param,leng,suffix)
    #print repr(buf.raw)

    #for test
    #b = struct.unpack_from(fmt,buf)
    #print b
    return buf</pre>
<p><strong>总结：</strong></p>
<p>可以用python 库struct 来完全对应C语言的二进制通信，解决跨语言通信问题</p>
<p><strong>参考：</strong></p>
<p><a href="http://docs.python.org/library/struct.html#module-struct">http://docs.python.org/library/struct.html#module-struct</a></p>
<p><a href="http://stackoverflow.com/questions/3753589/packing-and-unpacking-variable-length-array-string-using-the-struct-module-in-py">http://stackoverflow.com/questions/3753589/packing-and-unpacking-variable-length-array-string-using-the-struct-module-in-py</a></p>


<p>相关博文：<ol><li><a href='http://abloz.com/2011/09/07/c-language-the-url-to-the-code-submit-content-to-the-site.html' rel='bookmark' title='Permanent Link: C语言的url转码，提交内容到网站'>C语言的url转码，提交内容到网站</a></li>
<li><a href='http://abloz.com/2010/12/15/sizeof-32-bit-and-64-bit-compatibility.html' rel='bookmark' title='Permanent Link: sizeof的32位和64位兼容问题'>sizeof的32位和64位兼容问题</a></li>
<li><a href='http://abloz.com/2011/01/31/python-berkeley-db-trial.html' rel='bookmark' title='Permanent Link: python berkeley db试用'>python berkeley db试用</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/12/28/python-shi-xian-he-c-di-ip-socket-tong-xin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux 服务启动失败？</title>
		<link>http://abloz.com/2011/10/15/linux-fu-wu-qi-dong-shi-bai.html</link>
		<comments>http://abloz.com/2011/10/15/linux-fu-wu-qi-dong-shi-bai.html#comments</comments>
		<pubDate>Sat, 15 Oct 2011 04:40:56 +0000</pubDate>
		<dc:creator>梦想家</dc:creator>
				<category><![CDATA[技术]]></category>

		<guid isPermaLink="false">http://abloz.com/?p=1465</guid>
		<description><![CDATA[在/etc/rc.d/init.d/里面写个脚本test
执行service test start
结果提示：

env: /etc/init.d/test: No such file or directory
可是ls一下该文件却存在。
脚本看起来也没有问题。
原来，该脚本是从windows过去的[......]<p class='read-more'><a href='http://abloz.com/2011/10/15/linux-fu-wu-qi-dong-shi-bai.html'><img  src='../wp-content/themes/default/images/readmore.png' title='read more ... ' alt='Read More ...' onMouseOver='src='../wp-content/themes/default/images/readmore2.png'' onMouseOut='src='../wp-content/themes/default/images/readmore.png''></a></p>


相关博文：<ol><li><a href='http://abloz.com/2006/09/02/linux-regular-expression-tool.html' rel='bookmark' title='Permanent Link: linux 正则表达式工具'>linux 正则表达式工具</a></li>
<li><a href='http://abloz.com/2010/03/30/linux-time-server-settings.html' rel='bookmark' title='Permanent Link: linux设置时间服务器'>linux设置时间服务器</a></li>
<li><a href='http://abloz.com/2009/03/23/bash-script-format-errors-caused-by.html' rel='bookmark' title='Permanent Link: bash 脚本格式引起的错误'>bash 脚本格式引起的错误</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>在/etc/rc.d/init.d/里面写个脚本test</p>
<p>执行service test start</p>
<p>结果提示：</p>
<pre>
env: /etc/init.d/test: No such file or directory</pre>
<p>可是ls一下该文件却存在。</p>
<p>脚本看起来也没有问题。</p>
<p>原来，该脚本是从windows过去的，分行有问题。</p>
<p>用tr -d &#8216;\r&#8217; &lt; test &gt;test1</p>
<p>将换行去掉。结果，就可以执行了。</p>
<p>&nbsp;</p>


<p>相关博文：<ol><li><a href='http://abloz.com/2006/09/02/linux-regular-expression-tool.html' rel='bookmark' title='Permanent Link: linux 正则表达式工具'>linux 正则表达式工具</a></li>
<li><a href='http://abloz.com/2010/03/30/linux-time-server-settings.html' rel='bookmark' title='Permanent Link: linux设置时间服务器'>linux设置时间服务器</a></li>
<li><a href='http://abloz.com/2009/03/23/bash-script-format-errors-caused-by.html' rel='bookmark' title='Permanent Link: bash 脚本格式引起的错误'>bash 脚本格式引起的错误</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://abloz.com/2011/10/15/linux-fu-wu-qi-dong-shi-bai.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

