<?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://sillydong.com/feed" rel="self" type="application/rss+xml" />
	<link>http://sillydong.com</link>
	<description>与您分享学习Linux、C、Java的乐趣！</description>
	<lastBuildDate>Mon, 26 Mar 2012 01:49:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>简单高效的iptables管理shell脚本</title>
		<link>http://sillydong.com/myserver/iptables-management-shell.html</link>
		<comments>http://sillydong.com/myserver/iptables-management-shell.html#comments</comments>
		<pubDate>Mon, 26 Mar 2012 01:49:06 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[FORWARD]]></category>
		<category><![CDATA[INPUT]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[防火墙]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=683</guid>
		<description><![CDATA[服务器安全是个大问题，一般使用linux服务器，用得最多，最基础的就是iptables防火墙了。关于iptables详细用法可以参考我另一篇日志：我的iptables总结，本文将与大家分享一下一个简单方便的脚本用于管理iptables服务，相对于采用service的管理方式更加灵活。 需要注意的是，由于启用了iptables防火墙，FTP的主被动模式方面需要留意一下。众所周知FTP使用的是21端口，但是在我们进行FTP文件传输时，客户端首先连接到21端口，进行用户的认证，认证成功后，当我们要传输文件时，服务器会开一个端口为20来进行传输数据文件，也就是说，端口20才是真正传输所用到的端口，端口21只用于FTP的登陆认证。例如使用vsftpd做ftp时，可以使用下面的配置来限制端口访问，并且方便iptables规则设置： [bash] pasv_min_port=2222 pasv_max_port=2225 [/bash] 脚本如下： [bash] #!/bin/bash # By Chen.Zhidong # http://sillydong.com # Email:njutczd+gmail.com PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH #Begin start(){ #kernal setting echo “Kernal Setting&#8230;” echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route echo 0 &#8230; <a href="http://sillydong.com/myserver/iptables-management-shell.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>服务器安全是个大问题，一般使用linux服务器，用得最多，最基础的就是iptables防火墙了。关于iptables详细用法可以参考我另一篇日志：<a title="我的iptables总结" href="http://sillydong.com/myserver/iptables-rules-summary.html">我的iptables总结</a>，本文将与大家分享一下一个简单方便的脚本用于管理iptables服务，相对于采用service的管理方式更加灵活。<span id="more-683"></span></p>
<p>需要注意的是，由于启用了iptables防火墙，FTP的主被动模式方面需要留意一下。众所周知FTP使用的是21端口，但是在我们进行FTP文件传输时，客户端首先连接到21端口，进行用户的认证，认证成功后，当我们要传输文件时，服务器会开一个端口为20来进行传输数据文件，也就是说，端口20才是真正传输所用到的端口，端口21只用于FTP的登陆认证。例如使用vsftpd做ftp时，可以使用下面的配置来限制端口访问，并且方便iptables规则设置：</p>
<p>[bash]<br />
pasv_min_port=2222<br />
pasv_max_port=2225<br />
[/bash]</p>
<p>脚本如下：</p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen.Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>#Begin<br />
start(){<br />
	#kernal setting<br />
	echo “Kernal Setting&#8230;”<br />
	echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts<br />
	echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses<br />
	echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route<br />
	echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects<br />
	echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects<br />
	echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter<br />
	echo 1 > /proc/sys/net/ipv4/tcp_syncookies<br />
	echo 3 > /proc/sys/net/ipv4/tcp_retries1<br />
	echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout<br />
	echo 1400 > /proc/sys/net/ipv4/tcp_keepalive_time<br />
	echo 0 > /proc/sys/net/ipv4/tcp_window_scaling<br />
	echo 0 > /proc/sys/net/ipv4/tcp_sack<br />
	echo 0 > /proc/sys/net/ipv4/tcp_timestamps</p>
<p>	#iptables setting<br />
	echo “Iptables Setting&#8230;”<br />
	#default policy<br />
	iptables -P INPUT DROP<br />
	iptables -P OUTPUT ACCEPT<br />
	#clear original rules<br />
	iptables -F<br />
	#input rule<br />
	iptables -A INPUT -i lo -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 22 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 5666 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 20 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 21 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 22 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 25 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 80 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 110 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 143 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 443 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 873 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m tcp &#8211;dport 3306 -j ACCEPT<br />
	iptables -A INPUT -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 21 -j ACCEPT<br />
	iptables -A INPUT -p tcp &#8211;dport 2222:2225 -j ACCEPT<br />
	iptables -A INPUT -p icmp -m icmp &#8211;icmp-type 8 -j DROP<br />
	iptables -A INPUT -p all -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<br />
	iptables -A INPUT -p all -m state &#8211;state INVALID,NEW -j DROP</p>
<p>	BADIPS=”`curl -s http://feeds.dshield.org/block.txt | awk &#8216;/^[1-9]/ {print $1 “/” $3}&#8217;`”<br />
	if [ "$BADIPS" ];then<br />
		for ip in $BADIPS<br />
		do<br />
			iptables -I INPUT -s $ip -j DROP<br />
		done<br />
	fi<br />
}</p>
<p>stop(){<br />
	echo “Cleaning your Iptables:&#8230;”<br />
	iptables -F<br />
	iptables -X<br />
	iptables -Z<br />
	iptables -P INPUT ACCEPT<br />
	iptables -P OUTPUT ACCEPT<br />
	/etc/init.d/iptables stop<br />
	if [ "$?" == "0" ];then<br />
		echo “Done!”<br />
	fi<br />
}</p>
<p>case “$1&#8243; in<br />
start)<br />
	start<br />
	;;<br />
stop)<br />
	stop<br />
	;;<br />
restart)<br />
	stop &#038;&#038; start<br />
	;;<br />
*)<br />
	echo $”Usage: $0 {start|stop|restart}”<br />
	exit 1<br />
esac<br />
exit 0<br />
#End<br />
[/bash]</p>
<p>将它添加到rc.local中使能开机启动。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li><li>2011 年 07 月 22 日 -- <a href="http://sillydong.com/myshell/dot-file-show-hide.html" title="苹果系统显示隐藏文件切换脚本">苹果系统显示隐藏文件切换脚本</a></li><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html" title="用shell来为rsyncd增加删除站点配置">用shell来为rsyncd增加删除站点配置</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/iptables-management-shell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简单化Linux下find操作的脚本分享</title>
		<link>http://sillydong.com/myserver/linux-find-shell.html</link>
		<comments>http://sillydong.com/myserver/linux-find-shell.html#comments</comments>
		<pubDate>Thu, 15 Mar 2012 05:45:38 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[fgrep]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=678</guid>
		<description><![CDATA[最近做了一些Shell工具，用来简化运维工作，加快问题处理速度。此处分享一个根据find命令组合的脚本，能够用来在指定目录下对指定后缀的文件搜索指定关键词或者在指定目录下根据指定的修改时间进行搜索文件。代码其实非常简单，如下： [bash] #!/bin/bash # By Chen.Zhidong # http://sillydong.com # Email:njutczd+gmail.com PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH #Begin usage(){ echo -e “find files\nUsage: $0 {s directory extension keyword&#124;t directory [d&#124;m] num extension}” exit 0 } if [ $# -lt 4 ];then usage else case &#8230; <a href="http://sillydong.com/myserver/linux-find-shell.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近做了一些Shell工具，用来简化运维工作，加快问题处理速度。此处分享一个根据find命令组合的脚本，能够用来在指定目录下对指定后缀的文件搜索指定关键词或者在指定目录下根据指定的修改时间进行搜索文件。代码其实非常简单，如下：<span id="more-678"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen.Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>#Begin<br />
usage(){<br />
	echo -e “find files\nUsage: $0 {s directory extension keyword|t directory [d|m] num extension}”<br />
	exit 0<br />
}</p>
<p>if [ $# -lt 4 ];then<br />
	usage<br />
else<br />
	case $1 in<br />
	s)<br />
		if [ -e $2 -a -d $2 ];then<br />
			find -P $2 -type f -name “*.$3&#8243; | xargs fgrep -n -H -R -s -l “$4&#8243; | xargs ls -lh<br />
		else<br />
			echo “$2 not exist or not a directory”<br />
			exit 1<br />
		fi<br />
		;;<br />
	t)<br />
		if [ $# -lt 5 ];then<br />
			usage<br />
		else<br />
			if [ -e $2 -a -d $2 ];then<br />
				case $3 in<br />
				d)<br />
					find -P $2 -type f -name “*.$5&#8243; -ctime $4<br />
					;;<br />
				m)<br />
					find -P $2 -type f -name “*.$5&#8243; -cmin $4<br />
					;;<br />
				*)<br />
					usage<br />
					;;<br />
				esac<br />
			else<br />
				echo “$2 not exist or not a directory”<br />
				exit 1<br />
			fi<br />
		fi<br />
		;;<br />
	*)<br />
		usage<br />
		;;<br />
	esac<br />
fi<br />
exit $?<br />
#End<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/clean-black-chain.html" title="分享一个Linux上清除黑链的脚本">分享一个Linux上清除黑链的脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/linux-find-shell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell下判断输入是否合法IP</title>
		<link>http://sillydong.com/myshell/shell-validate-ip-bas.html</link>
		<comments>http://sillydong.com/myshell/shell-validate-ip-bas.html#comments</comments>
		<pubDate>Mon, 12 Mar 2012 03:34:07 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[121.0.0.1]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ip地址]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[匹配]]></category>
		<category><![CDATA[正则]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=673</guid>
		<description><![CDATA[最近在做一些服务器安全方面的shell，有用到判断输入是否合法ip地址。在网上搜了一圈，有很多做法，最简单的就是直接判断输入内容是否全部为数字和“.”符号，这样的判断太范了，无法做到准确。更准确一些的就包含了字符个数等。后来找到了一个比较严谨的做法，经验证的确可用，代码如下： <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近在做一些服务器安全方面的shell，有用到判断输入是否合法ip地址。在网上搜了一圈，有很多做法，最简单的就是直接判断输入内容是否全部为数字和“.”符号，这样的判断太范了，无法做到准确。更准确一些的就包含了字符个数等。后来找到了一个比较严谨的做法，经验证的确可用，代码如下：<span id="more-673"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen.Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>#Begin<br />
usage(){<br />
	echo -e “valid ipaddress\nUsage: $0 ipaddress”<br />
	exit 0<br />
}</p>
<p>valid_ip(){<br />
    local  ip=$1<br />
    local  stat=1<br />
    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then<br />
        OIFS=$IFS<br />
        IFS=&#8217;.&#8217;<br />
        ip=($ip)<br />
        IFS=$OIFS<br />
        [[ ${ip[0]} -le 255 &#038;&#038; ${ip[1]} -le 255 &#038;&#038; ${ip[2]} -le 255 &#038;&#038; ${ip[3]} -le 255 ]]<br />
        stat=$?<br />
    fi<br />
    return $stat<br />
}</p>
<p>if [ $# -lt 1 ];then<br />
	usage<br />
else<br />
	if valid_ip “$1&#8243;;then<br />
		echo “$1 is valid ip address”<br />
	else<br />
		echo “$1 is INVALID ip address”<br />
	fi<br />
fi<br />
exit 0<br />
#End<br />
[/bash]</p>
<p>出处：<a href="http://www.linuxjournal.com/content/validating-ip-address-bash-script">http://www.linuxjournal.com/content/validating-ip-address-bash-script</a></p>
<p>看官有需求的可以参考一下。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 07 月 22 日 -- <a href="http://sillydong.com/myshell/dot-file-show-hide.html" title="苹果系统显示隐藏文件切换脚本">苹果系统显示隐藏文件切换脚本</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/clean-black-chain.html" title="分享一个Linux上清除黑链的脚本">分享一个Linux上清除黑链的脚本</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2010 年 09 月 26 日 -- <a href="http://sillydong.com/myshell/bash-operator.html" title="Bash脚本编程中的操作符简述">Bash脚本编程中的操作符简述</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/shell-validate-ip-bas.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android手机短信SMSC算法</title>
		<link>http://sillydong.com/myjava/android-smsc.html</link>
		<comments>http://sillydong.com/myjava/android-smsc.html#comments</comments>
		<pubDate>Sun, 04 Mar 2012 15:38:05 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[10086]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[smsc]]></category>
		<category><![CDATA[短信]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=666</guid>
		<description><![CDATA[今天手机不幸又发不出短信了，打10086确认了一下没停机之后就到*#*#4636#*#*里面看SMSC的设置，发现果然和上次发不了短信一样的毛病，没办法，只好找这SMSC的值了。恰好上次看到了一片文章，讲到了这个值的算法，干脆今天就写个程序出来吧，免得下次又烦。主要的函数如下，并附上打包好的可执行jar文件。 <a href="http://sillydong.com/myjava/android-smsc.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天手机不幸又发不出短信了，打10086确认了一下没停机之后就到*#*#4636#*#*里面看SMSC的设置，发现果然和上次发不了短信一样的毛病，没办法，只好找这SMSC的值了。恰好上次看到了一片文章，讲到了这个值的算法，干脆今天就写个程序出来吧，免得下次又烦。主要的函数如下，并附上打包好的可执行jar文件。</p>
<p><span id="more-666"></span></p>
<p>1. 找到自己所在地的短信中心号码。比如南京就是+8613800250500<br /> 2. 取“+”后面的数字，在最后补上“F”<br /> 3. 把数字两两反转成为68 31 08 20 05 05 F0这样的结果<br /> 4. 然后字符串前要面加上08 91, 如果你去香港澳门,你的地址信息的长度少了一点,可能要改为0791。08 地址信息的长度是八位字节(包括91),91 SMSC地址格式(TON/NPI)用国际格式号码(在前面加‘+’)<br /> 5. 最后你的SMSC编码就是0891683108200505F0<br /> 6. 打开拨号画面,按*#*#4636#*#*, 选手机信息,拉到下面的SMSC<br /> 7. 把0891683108200505F0填进去, 按更新<br /> 8. 设置到飞行模式后关闭飞行模式，应该就可以了，不行就重启下手机~</p>
<p>[java]<br />
private String generate(String _number) {<br />
	char[] number = (_number + &#8216;F&#8217;).toCharArray();<br />
	char tmp;<br />
	for (int i = 0; i < 14; i++) {<br />
		tmp = number[i];<br />
		number[i] = number[i + 1];<br />
		number[i + 1] = tmp;<br />
		i++;<br />
	}<br />
	return "0891" + String.valueOf(number);<br />
}<br />
[/java]</p>
</p>
<p>附上适用于江苏地区的编码器，下载后解压zip文件结果的jar文件即是。请先安装<a title="JRE下载" href="http://www.java.com/zh_CN/download/" target="_blank">JRE</a></p>
<p><a href="http://sillydong.com/wp-content/uploads/2012/03/SMS-Generator.jar_.zip">SMS Generator.jar</a> </p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 26 日 -- <a href="http://sillydong.com/myjava/android-md5-base64-encode-decode.html" title="Android MD5加密类和Base64编解码类">Android MD5加密类和Base64编解码类</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-smsc.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac OS X Lion与Xcode 4.3以及Homebrew的故事</title>
		<link>http://sillydong.com/mymacos/mac-os-x-lion-xcode-homebrew.html</link>
		<comments>http://sillydong.com/mymacos/mac-os-x-lion-xcode-homebrew.html#comments</comments>
		<pubDate>Fri, 02 Mar 2012 05:13:21 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[automake]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macport]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[xcode]]></category>
		<category><![CDATA[开发者]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=664</guid>
		<description><![CDATA[用Lion也有段时间了。总的来说有好的也有坏的，好的不多说，咱说说它的缺点，顺便吐槽一下开发者常用的Xcode和Homebrew。 <a href="http://sillydong.com/mymacos/mac-os-x-lion-xcode-homebrew.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>用Lion也有段时间了。总的来说有好的也有坏的，好的不多说，咱说说它的缺点，顺便吐槽一下开发者常用的Xcode和Homebrew。<span id="more-664"></span></p>
<p>1、开机慢了。机械硬盘，320G5400转，原装的。还记得SnowLeopad开机时候菊花转上十多圈就进系统了，现在Lion得转上二三十圈，等的那叫人一个纠结啊。</p>
<p>2、关机时候非得留意把下次开机重新打开窗口的勾勾去掉，虽然网上也有处理办法，例如<a href="http://mac.pcbeta.com/thread-75825-1-1.html">http://mac.pcbeta.com/thread-75825-1-1.html</a>，傻东我不大喜欢，就没有这么干。</p>
<p>以上是两个Lion上最大的问题。下面说说Xcode。</p>
<p>之前一段时间用的是Xcode的4.2，和以前的应该来说差不多，没多大问题。前段时间因为菊花问题，重装了系统，再从AppStore安装xcode就装了4.3。前几天要编译一个软件时候出问题了，找不到gcc、make，啥都没了。打开Xcode研究了下，才发现还要装commandline tool。在Preference里面Download下。安装一下才行。好麻烦！如果你以为这就完了那就错了，麻烦的还不止这个！缺少automake、autoconf，啥都没，真是。。。最后上homebrew装上了这些。</p>
<p>Homebrew是个好东西，用起来比macport方便。网上有很多相关资料，看官可以Google之。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 07 月 22 日 -- <a href="http://sillydong.com/myshell/dot-file-show-hide.html" title="苹果系统显示隐藏文件切换脚本">苹果系统显示隐藏文件切换脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mymacos/mac-os-x-lion-xcode-homebrew.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP用preg_match进行各种验证总结</title>
		<link>http://sillydong.com/myweb/php-preg_match-summary.html</link>
		<comments>http://sillydong.com/myweb/php-preg_match-summary.html#comments</comments>
		<pubDate>Fri, 02 Mar 2012 04:56:42 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[WEB]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[preg_match]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=659</guid>
		<description><![CDATA[整理了一批php中使用preg_match进行内容判断的函数做成了一个类，可以直接用，涵盖了大部分常用的判断，各位看官慢慢欣赏～代码如下 <a href="http://sillydong.com/myweb/php-preg_match-summary.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>整理了一批php中使用preg_match进行内容判断的函数做成了一个类，可以直接用，涵盖了大部分常用的判断，各位看官慢慢欣赏～代码如下<span id="more-659"></span></p>
<p>[php]<br />
< ?php<br />
/**<br />
 *<br />
 * @author Chen.Zhidong<br />
 * 2012-1-17<br />
 *<br />
 */</p>
<p>class Validate{<br />
	public static function isEmail($email){<br />
		return preg_match('/^[a-z0-9!#$%&#038;\'*+\/=?^`{}|~_-]+[.a-z0-9!#$%&#038;\'*+\/=?^`{}|~_-]*@[a-z0-9]+[._a-z0-9-]*\.[a-z0-9]+$/ui', $email);<br />
	}</p>
<p>	public static function isMD5($md5){<br />
		return preg_match('/^[a-z0-9]{32}$/ui', $md5);<br />
	}</p>
<p>	public static function isSHA1($sha1){<br />
		return preg_match('/^[a-z0-9]{40}$/ui', $sha1);<br />
	}</p>
<p>	public static function isPasswd($passwd,$size=6){<br />
		return preg_match('/^[.a-z_0-9-!@#$%\^&#038;*()]{'.$size.',32}$/ui', $passwd);<br />
	}</p>
<p>	public static function isName($name){<br />
		return preg_match('/^[^0-9!<>,;?=+()@#”°{}_$%:]*$/ui&#8217;, stripslashes($name));<br />
	}</p>
<p>	public static function isFloat($float){<br />
		return strval(floatval($float)) == strval($float);<br />
	}</p>
<p>	public static function isUnsignedFloat($float){<br />
		return strval(floatval($float)) == strval($float) &#038;&#038; $float >= 0;<br />
	}</p>
<p>	public static function isOptFloat($float){<br />
		return empty($float) || self::isFloat($float);<br />
	}</p>
<p>	public static function isInt($value){<br />
		return ((string)(int)$value === (string)$value || $value === false);<br />
	}</p>
<p>	public static function isUnsignedInt($value){<br />
		return (self::isInt($value) &#038;&#038; $value < 4294967296 &#038;&#038; $value >= 0);<br />
	}</p>
<p>	public static function isUrl($url){<br />
		return preg_match(&#8216;/^([[:alnum:]]|[:#%&#038;_=\(\)\.\? \+\-@\/])+$/ui&#8217;, $url);<br />
	}</p>
<p>	public static function isAbsoluteUrl($url){<br />
		if (!empty($url))<br />
			return preg_match(&#8216;/^https?:\/\/([[:alnum:]]|[:#%&#038;_=\(\)\.\? \+\-@\/\$])+$/ui&#8217;, $url);<br />
		return true;<br />
	}</p>
<p>	public static function isSortDirection($value){<br />
		return (!is_null($value) &#038;&#038; ($value === &#8216;ASC&#8217; || $value === &#8216;DESC&#8217;));<br />
	}</p>
<p>	public static function isImageFile($filename){<br />
		return preg_match(&#8216;/^[a-z0-9_-]+\.[jpg|jpeg|png|bmp|gif]$/ui&#8217;, $filename);<br />
	}</p>
<p>	public static function isString($string){<br />
		return is_string($string);<br />
	}</p>
<p>	public static function isCleanString($string){<br />
		return preg_match(&#8216;/^[^\'"]+$/ui&#8217;, $string);<br />
	}</p>
<p>	public static function isDate($date){<br />
		if (!preg_match(&#8216;/^([0-9]{4})-((0?[1-9])|(1[0-2]))-((0?[1-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/ui&#8217;, $date, $matches))<br />
			return false;<br />
		return checkdate(intval($matches[2]), intval($matches[5]), intval($matches[0]));<br />
	}</p>
<p>	public static function isBool($bool){<br />
		return is_null($bool) || is_bool($bool) || preg_match(&#8216;/^[0|1]{1}$/ui&#8217;, $bool);<br />
	}</p>
<p>	public static function isAddress($address){<br />
		return empty($address) || preg_match(&#8216;/^[^!<>?=+@{}_$%]*$/ui&#8217;, $address);<br />
	}</p>
<p>	public static function isUnsignedId($id){<br />
		return self::isUnsignedInt($id);<br />
	}<br />
}<br />
?><br />
[/php]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 01 月 29 日 -- <a href="http://sillydong.com/mypython/functions-of-digital-in-python.html" title="Python笔记——数字类型的几个函数">Python笔记——数字类型的几个函数</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myweb/php-preg_match-summary.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android MD5加密类和Base64编解码类</title>
		<link>http://sillydong.com/myjava/android-md5-base64-encode-decode.html</link>
		<comments>http://sillydong.com/myjava/android-md5-base64-encode-decode.html#comments</comments>
		<pubDate>Mon, 26 Dec 2011 13:56:36 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[decode]]></category>
		<category><![CDATA[encode]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[加密]]></category>
		<category><![CDATA[算法]]></category>
		<category><![CDATA[解密]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=641</guid>
		<description><![CDATA[Android代码分享第五弹：一个实用的MD5加密类和BASE64编解码类。可能会有看官说这两个小功能，随便调用一下android的代码就OK了，但是当时我在搜索相关内容时还是发现，很多人提出相关的问题，并且还有很多乱七八糟的答案，尤其是MD5加密的类，竟然有个答案是会造成所有0消失，大错特错啊！于是花时间自己整理了一下，写出来，与诸位共享。 <a href="http://sillydong.com/myjava/android-md5-base64-encode-decode.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Android代码分享第五弹：一个实用的MD5加密类和BASE64编解码类。可能会有看官说这两个小功能，随便调用一下android的代码就OK了，但是当时我在搜索相关内容时还是发现，很多人提出相关的问题，并且还有很多乱七八糟的答案，尤其是MD5加密的类，竟然有个答案是会造成所有0消失，大错特错啊！于是花时间自己整理了一下，写出来，与诸位共享。<span id="more-641"></span></p>
<p>先看MD5加密的代码，先调用MessageDigest，然后取HashString，返回的是大写的，看官也可以用小写的，看需要。</p>
<p>[java]<br />
package czd.android.utils;</p>
<p>import java.security.MessageDigest;<br />
import java.security.NoSuchAlgorithmException;</p>
<p>/**<br />
 *<br />
 * @author Chen.Zhidong<br />
 *         2011-12-21<br />
 *<br />
 */<br />
public class MD5EncodeUtil {</p>
<p>	public static String MD5Encode(byte[] toencode) {<br />
		try {<br />
			MessageDigest md5 = MessageDigest.getInstance(“MD5&#8243;);<br />
			md5.reset();<br />
			md5.update(toencode);<br />
			return HexEncode(md5.digest());<br />
		} catch (NoSuchAlgorithmException e) {<br />
			e.printStackTrace();<br />
		}<br />
		return “”;<br />
	}</p>
<p>	public static String HexEncode(byte[] toencode) {<br />
		StringBuilder sb = new StringBuilder(toencode.length * 2);<br />
		for(byte b: toencode){<br />
			sb.append(Integer.toHexString((b &#038; 0xf0) >>> 4));<br />
			sb.append(Integer.toHexString(b &#038; 0x0f));<br />
		}<br />
		return sb.toString().toUpperCase();<br />
	}<br />
}<br />
[/java]</p>
<p>然后是BASE64编解码的代码，整理自网络，仅限于对字符串进行编解码，这是我需要的，相对来说效率可以，算法也没错，简单明了，看看。</p>
<p>[java]<br />
package czd.android.utils;</p>
<p>import java.io.ByteArrayOutputStream;</p>
<p>public class Base64Util {<br />
	private static final char[] base64EncodeChars = new char[] { &#8216;A&#8217;, &#8216;B&#8217;, &#8216;C&#8217;, &#8216;D&#8217;, &#8216;E&#8217;, &#8216;F&#8217;, &#8216;G&#8217;, &#8216;H&#8217;, &#8216;I&#8217;, &#8216;J&#8217;, &#8216;K&#8217;, &#8216;L&#8217;, &#8216;M&#8217;, &#8216;N&#8217;, &#8216;O&#8217;, &#8216;P&#8217;, &#8216;Q&#8217;, &#8216;R&#8217;, &#8216;S&#8217;, &#8216;T&#8217;, &#8216;U&#8217;, &#8216;V&#8217;, &#8216;W&#8217;, &#8216;X&#8217;, &#8216;Y&#8217;, &#8216;Z&#8217;, &#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;, &#8216;d&#8217;, &#8216;e&#8217;, &#8216;f&#8217;, &#8216;g&#8217;, &#8216;h&#8217;, &#8216;i&#8217;, &#8216;j&#8217;, &#8216;k&#8217;, &#8216;l&#8217;, &#8216;m&#8217;, &#8216;n&#8217;, &#8216;o&#8217;, &#8216;p&#8217;, &#8216;q&#8217;, &#8216;r&#8217;, &#8216;s&#8217;, &#8216;t&#8217;, &#8216;u&#8217;, &#8216;v&#8217;, &#8216;w&#8217;, &#8216;x&#8217;, &#8216;y&#8217;, &#8216;z&#8217;, &#8217;0&#8242;, &#8217;1&#8242;, &#8217;2&#8242;, &#8217;3&#8242;, &#8217;4&#8242;, &#8217;5&#8242;, &#8217;6&#8242;, &#8217;7&#8242;, &#8217;8&#8242;, &#8217;9&#8242;, &#8216;+&#8217;, &#8216;/&#8217; };</p>
<p>	private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 };</p>
<p>	private Base64Util() {<br />
	}</p>
<p>	/**<br />
	 * 将字节数组编码为字符串<br />
	 *<br />
	 * @param data<br />
	 */<br />
	public static String encode(byte[] data) {<br />
		StringBuffer sb = new StringBuffer();<br />
		int len = data.length;<br />
		int i = 0;<br />
		int b1, b2, b3;</p>
<p>		while (i < len) {<br />
			b1 = data[i++] &#038; 0xff;<br />
			if (i == len) {<br />
				sb.append(base64EncodeChars[b1 >>> 2]);<br />
				sb.append(base64EncodeChars[(b1 &#038; 0x3) < < 4]);<br />
				sb.append(“==”);<br />
				break;<br />
			}<br />
			b2 = data[i++] &#038; 0xff;<br />
			if (i == len) {<br />
				sb.append(base64EncodeChars[b1 >>> 2]);<br />
				sb.append(base64EncodeChars[((b1 &#038; 0x03) < < 4) | ((b2 &#038; 0xf0) >>> 4)]);<br />
				sb.append(base64EncodeChars[(b2 &#038; 0x0f) < < 2]);<br />
				sb.append(“=”);<br />
				break;<br />
			}<br />
			b3 = data[i++] &#038; 0xff;<br />
			sb.append(base64EncodeChars[b1 >>> 2]);<br />
			sb.append(base64EncodeChars[((b1 &#038; 0x03) < < 4) | ((b2 &#038; 0xf0) >>> 4)]);<br />
			sb.append(base64EncodeChars[((b2 &#038; 0x0f) < < 2) | ((b3 &#038; 0xc0) >>> 6)]);<br />
			sb.append(base64EncodeChars[b3 &#038; 0x3f]);<br />
		}<br />
		return sb.toString();<br />
	}</p>
<p>	/**<br />
	 * 将base64字符串解码为字节数组<br />
	 *<br />
	 * @param str<br />
	 */<br />
	public static byte[] decode(String str) {<br />
		byte[] data = str.getBytes();<br />
		int len = data.length;<br />
		ByteArrayOutputStream buf = new ByteArrayOutputStream(len);<br />
		int i = 0;<br />
		int b1, b2, b3, b4;</p>
<p>		while (i < len) {</p>
<p>			/* b1 */<br />
			do {<br />
				b1 = base64DecodeChars[data[i++]];<br />
			} while (i < len &#038;&#038; b1 == -1);<br />
			if (b1 == -1) {<br />
				break;<br />
			}</p>
<p>			/* b2 */<br />
			do {<br />
				b2 = base64DecodeChars[data[i++]];<br />
			} while (i < len &#038;&#038; b2 == -1);<br />
			if (b2 == -1) {<br />
				break;<br />
			}<br />
			buf.write((int) ((b1 << 2) | ((b2 &#038; 0x30) >>> 4)));</p>
<p>			/* b3 */<br />
			do {<br />
				b3 = data[i++];<br />
				if (b3 == 61) {<br />
					return buf.toByteArray();<br />
				}<br />
				b3 = base64DecodeChars[b3];<br />
			} while (i < len &#038;&#038; b3 == -1);<br />
			if (b3 == -1) {<br />
				break;<br />
			}<br />
			buf.write((int) (((b2 &#038; 0x0f) << 4) | ((b3 &#038; 0x3c) >>> 2)));</p>
<p>			/* b4 */<br />
			do {<br />
				b4 = data[i++];<br />
				if (b4 == 61) {<br />
					return buf.toByteArray();<br />
				}<br />
				b4 = base64DecodeChars[b4];<br />
			} while (i < len &#038;&#038; b4 == -1);<br />
			if (b4 == -1) {<br />
				break;<br />
			}<br />
			buf.write((int) (((b3 &#038; 0x03) << 6) | b4));<br />
		}<br />
		return buf.toByteArray();<br />
	}<br />
}<br />
[/java]</p></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 04 日 -- <a href="http://sillydong.com/myjava/android-smsc.html" title="Android手机短信SMSC算法">Android手机短信SMSC算法</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-md5-base64-encode-decode.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android URL链接生成函数</title>
		<link>http://sillydong.com/myjava/android-url-construct.html</link>
		<comments>http://sillydong.com/myjava/android-url-construct.html#comments</comments>
		<pubDate>Thu, 22 Dec 2011 16:00:24 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[httpget]]></category>
		<category><![CDATA[httppost]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[namevaluepair]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=635</guid>
		<description><![CDATA[代码分享第四弹，URL生成函数。其实这真的是闲的蛋疼的需求才会用到的函数，将各种形式组织的数据做成带?和&#38;的链接，闲的蛋疼才会用这个，正常都用POST来做，具体的方法可以看我前一篇文章 <a href="http://sillydong.com/myjava/android-http-methods.html" target="_blank">Android获取网页数据的方法总结</a> 里面有POST的用法。一会儿会放出GET的方法，往下看就是了 <a href="http://sillydong.com/myjava/android-url-construct.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>代码分享第四弹，URL生成函数。其实这真的是闲的蛋疼的需求才会用到的函数，将各种形式组织的数据做成带?和&amp;的链接，闲的蛋疼才会用这个，正常都用POST来做，具体的方法可以看我前一篇文章 <a href="http://sillydong.com/myjava/android-http-methods.html" target="_blank">Android获取网页数据的方法总结</a> 里面有POST的用法。一会儿会放出GET的方法，往下看就是了<span id="more-635"></span></p>
<p>对于几个没太大用处的类就不多说啥了，看官随便看看：</p>
<p>[java]<br />
/**<br />
 * @param params<br />
 * @return<br />
 */<br />
public static String urlCombiner(Map<string , String> params) {<br />
	if (params != null &#038;&#038; !params.isEmpty()) {<br />
		StringBuilder url = new StringBuilder();<br />
		boolean first = true;<br />
		for (String key : params.keySet()) {<br />
			if (first) {<br />
				first = false;<br />
				url.append(&#8216;?&#8217;);<br />
			}<br />
			else {<br />
				url.append(&#8216;&#038;&#8217;);<br />
			}<br />
			url.append(key + &#8216;=&#8217; + params.get(key));<br />
		}<br />
		return url.toString();</p>
<p>	}<br />
	return “”;<br />
}</p>
<p>/**<br />
 * @param nameValuePairs<br />
 * @return<br />
 */<br />
public static String urlCombiner(ArrayList<namevaluepair> nameValuePairs) {<br />
	if (nameValuePairs != null &#038;&#038; !nameValuePairs.isEmpty()) {<br />
		StringBuilder url = new StringBuilder();<br />
		int len = nameValuePairs.size();<br />
		for (int i = 0; i < len; i++) {<br />
			if (i == 0) {<br />
				url.append('?');<br />
			}<br />
			else {<br />
				url.append('&#038;');<br />
			}<br />
			url.append(nameValuePairs.get(i).getName() + '=' + nameValuePairs.get(i).getValue());<br />
		}<br />
		return url.toString();<br />
	}<br />
	return "";<br />
}</p>
<p>/**<br />
 * @param params<br />
 * @return<br />
 */<br />
public static String urlCombiner(Bundle params) {<br />
	if (params == null)<br />
		return "";<br />
	StringBuilder sb = new StringBuilder();<br />
	boolean first = true;<br />
	for (String key : params.keySet()) {<br />
		if (first) {<br />
			first = false;<br />
			sb.append("?");<br />
		}<br />
		else {<br />
			sb.append("&#038;");<br />
		}<br />
		sb.append(key + "=" + params.getString(key));<br />
	}<br />
	return sb.toString();<br />
}<br />
[/java]</p>
<p>下面是GET的函数，随便看下，用的HTTPGET，里面就用了上面三个函数中的某个，见代码。</p>
<p>[java]<br />
/**<br />
 * @param nameValuePairs<br />
 * @param url<br />
 * @return<br />
 */<br />
public static InputStream doGet(ArrayList<namevaluepair> nameValuePairs, String url) {<br />
	HttpClient httpclient = new DefaultHttpClient();<br />
	try {<br />
		String target = url + urlCombiner(nameValuePairs);<br />
		HttpGet httpget = new HttpGet(target);<br />
		HttpResponse response = httpclient.execute(httpget);<br />
		if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {<br />
			return response.getEntity().getContent();<br />
		}<br />
	} catch (Exception e) {<br />
		e.printStackTrace();<br />
	}/*finally {<br />
		httpclient.getConnectionManager().shutdown();<br />
	}*/<br />
	return null;<br />
}<br />
[/java]</namevaluepair></p>
<p></namevaluepair></string></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 05 月 08 日 -- <a href="http://sillydong.com/myjava/android-activity-finish.html" title="Android关闭所有Activity完全退出程序">Android关闭所有Activity完全退出程序</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-url-construct.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android数据库操作类，超实用！</title>
		<link>http://sillydong.com/myjava/android-sqlite-database.html</link>
		<comments>http://sillydong.com/myjava/android-sqlite-database.html#comments</comments>
		<pubDate>Wed, 21 Dec 2011 13:17:05 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[查询]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=632</guid>
		<description><![CDATA[Android代码分享第三弹：超实用的数据库操作类！在书里看到的，整理出来了，在原来的基础上又加了几个函数，并且新建数据库的那边也做了更改，判断所在目录有没有。最初使用时候经常发生错误，不能在程序私有空间建立数据库文件，后来才发现是路径问题，改了一下，从此有权限的地方都能建库！so easy!在查询那边加了一个用sql语句进行查询的函数，原来的那个函数不会用，还是直接sql方便。加了个复制数据库的函数。准备好数据库放在raw目录下，到时候用R.raw访问。 <a href="http://sillydong.com/myjava/android-sqlite-database.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Android代码分享第三弹：超实用的数据库操作类！在书里看到的，整理出来了，在原来的基础上又加了几个函数，并且新建数据库的那边也做了更改，判断所在目录有没有。最初使用时候经常发生错误，不能在程序私有空间建立数据库文件，后来才发现是路径问题，改了一下，从此有权限的地方都能建库！so easy!在查询那边加了一个用sql语句进行查询的函数，原来的那个函数不会用，还是直接sql方便。加了个复制数据库的函数。准备好数据库放在raw目录下，到时候用R.raw访问。<span id="more-632"></span></p>
<p>不多说，看代码：</p>
<p>[java]<br />
package czd.android.utils;</p>
<p>import java.io.File;<br />
import java.io.FileOutputStream;<br />
import java.io.InputStream;</p>
<p>import android.content.Context;<br />
import android.database.Cursor;<br />
import android.database.sqlite.SQLiteDatabase;</p>
<p>public class SQLiteUtil {</p>
<p>	public static final String SQLite_MASTER_TABLE = “sqlite_master”;<br />
	private static SQLiteUtil mInstance = new SQLiteUtil();</p>
<p>	/**<br />
	 *<br />
	 */<br />
	private SQLiteUtil() {<br />
	}</p>
<p>	/**<br />
	 * @return instance of SQLiteUtil<br />
	 */<br />
	public static SQLiteUtil getInstance() {<br />
		return SQLiteUtil.mInstance;<br />
	}</p>
<p>	/**<br />
	 * open or create a database with the given dbName:<br />
	 * /data/data/packagename/databases/databasefilename<br />
	 * /sdcard/databasefilename<br />
	 *<br />
	 * @param dbName<br />
	 * @return SQLiteDatabase<br />
	 */<br />
	private SQLiteDatabase openDB(String dbName) {<br />
		File file = new File(dbName);<br />
		if (file.exists() == true) {<br />
			return SQLiteDatabase.openDatabase(dbName, null, SQLiteDatabase.OPEN_READWRITE);<br />
		}else {<br />
			File datafiledir = file.getParentFile();<br />
			if(!datafiledir.exists()){<br />
				datafiledir.mkdirs();<br />
			}<br />
			return SQLiteDatabase.openOrCreateDatabase(dbName, null);<br />
		}<br />
	}</p>
<p>	/**<br />
	 * close database<br />
	 *<br />
	 * @param db<br />
	 */<br />
	private void closeDB(SQLiteDatabase db) {<br />
		db.close();<br />
	}</p>
<p>	/**<br />
	 * delete database<br />
	 *<br />
	 * @param dbName<br />
	 * @return boolean<br />
	 */<br />
	public boolean deleteDB(String dbName) {<br />
		File file = new File(dbName);<br />
		if (file.exists() == true) {<br />
			return file.delete();<br />
		}<br />
		return true;<br />
	}</p>
<p>	/**<br />
	 * execute sql command<br />
	 *<br />
	 * @param dbName<br />
	 * @param sql<br />
	 */<br />
	public void execQuery(String dbName, String sql) {<br />
		SQLiteDatabase db = openDB(dbName);<br />
		db.execSQL(sql);<br />
		closeDB(db);<br />
	}</p>
<p>	/**<br />
	 * execute sql command and return Cursor<br />
	 *<br />
	 * @param dbName<br />
	 * @param tableName<br />
	 * @param condStr<br />
	 * @return Cursor<br />
	 */<br />
	public Cursor openQuery(String dbName, String sql) {<br />
		SQLiteDatabase db = openDB(dbName);<br />
		Cursor cursor = db.rawQuery(sql, null);<br />
		cursor.moveToFirst();<br />
		closeDB(db);<br />
		return cursor;<br />
	}</p>
<p>	public Cursor openQuery(String dbName, String tableName, String condStr) {<br />
		SQLiteDatabase db = openDB(dbName);<br />
		Cursor cursor = db.query(tableName, null, condStr, null, null, null, null);<br />
		cursor.moveToFirst();<br />
		closeDB(db);<br />
		return (cursor);<br />
	}</p>
<p>	public int getRowsCount(Cursor cursor) {<br />
		return cursor.getCount();<br />
	}</p>
<p>	public int getColumnsCount(Cursor cursor) {<br />
		return cursor.getColumnCount();<br />
	}</p>
<p>	public String getColumnNameBy(Cursor cursor, int index) {<br />
		return cursor.getColumnName(index);<br />
	}</p>
<p>	public boolean isBOF(Cursor cursor) {<br />
		return cursor.isBeforeFirst();<br />
	}</p>
<p>	public boolean isEOF(Cursor cursor) {<br />
		return cursor.isAfterLast();<br />
	}</p>
<p>	public boolean moveNext(Cursor cursor) {<br />
		return cursor.moveToNext();<br />
	}</p>
<p>	public String getField(Cursor cursor, int index) {<br />
		return cursor.getString(index);<br />
	}</p>
<p>	public void closeQuery(Cursor cursor) {<br />
		cursor.close();<br />
	}</p>
<p>	public boolean isTableExists(String dbName, String tableName) {<br />
		Cursor cursor = openQuery(dbName, SQLite_MASTER_TABLE, “(tbl_name=&#8217;” + tableName + “&#8216;)”);<br />
		int recordCount = cursor.getCount();<br />
		cursor.close();<br />
		return (recordCount > 0);<br />
	}</p>
<p>	public boolean isDatabaseExists(String dbName){<br />
		return new File(dbName).exists();<br />
	}</p>
<p>	public static void copyDatabase(Context context, String dbName, int resourceId) {<br />
		try {<br />
			if (!(new File(dbName)).exists()) {<br />
				InputStream is = context.getResources().openRawResource(resourceId);<br />
				FileOutputStream fos = new FileOutputStream(dbName);<br />
				byte[] buffer = new byte[1024];<br />
				int count = 0;<br />
				while ((count = is.read(buffer)) > 0) {<br />
					fos.write(buffer, 0, count);<br />
				}<br />
				fos.close();<br />
				is.close();<br />
			}<br />
		}catch (Exception e) {<br />
			e.printStackTrace();<br />
		}<br />
	}<br />
};</p>
<p>[/java]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 05 月 08 日 -- <a href="http://sillydong.com/myjava/android-activity-finish.html" title="Android关闭所有Activity完全退出程序">Android关闭所有Activity完全退出程序</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-sqlite-database.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Java InputStream处理相关代码</title>
		<link>http://sillydong.com/myjava/android-inputstream-string-json.html</link>
		<comments>http://sillydong.com/myjava/android-inputstream-string-json.html#comments</comments>
		<pubDate>Tue, 20 Dec 2011 12:01:44 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[inputstream]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=626</guid>
		<description><![CDATA[代码分享第二集：关于InputStream处理的一些函数，主要是出于方便的目的，将InputStream转为String,JSONArray,JSONObject,byte。中间有些是由于本人使用环境的特殊性，那样写的，诸位看官可根据自己实际情况改。代码中提供了两种处理inputstream的方法，不说哪种效率更高，有兴趣可以用前一篇文章 <a title="Android计时器代码分享" href="http://sillydong.com/myjava/android-develop-timer.html" target="_blank">Android计时器代码分享</a> 里的代码来看看。 <a href="http://sillydong.com/myjava/android-inputstream-string-json.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>代码分享第二集：关于InputStream处理的一些函数，主要是出于方便的目的，将InputStream转为String,JSONArray,JSONObject,byte。中间有些是由于本人使用环境的特殊性，那样写的，诸位看官可根据自己实际情况改。代码中提供了两种处理inputstream的方法，不说哪种效率更高，有兴趣可以用前一篇文章 <a title="Android计时器代码分享" href="http://sillydong.com/myjava/android-develop-timer.html" target="_blank">Android计时器代码分享</a> 里的代码来看看。</p>
<p><span id="more-626"></span></p>
<p>下面贴代码，推荐用右边的分享按钮告诉你的朋友哦~有意见有想法的，欢迎留言吐槽！</p>
<p>[java]<br />
package shiyi.android.utils;</p>
<p>import java.io.BufferedReader;<br />
import java.io.ByteArrayOutputStream;<br />
import java.io.IOException;<br />
import java.io.InputStream;<br />
import java.io.InputStreamReader;<br />
import java.io.UnsupportedEncodingException;</p>
<p>import android.graphics.Bitmap;<br />
import android.graphics.BitmapFactory;<br />
import android.graphics.drawable.Drawable;</p>
<p>/**<br />
 * @author Chen.Zhidong<br />
 *<br />
 */<br />
public class StreamUtil {<br />
	/**<br />
	 * InputStream转String<br />
	 * 这里用的方法和下面一个函数方法不同，看官看到下面的函数自然会明白<br />
	 * @param is<br />
	 * @param encode<br />
	 * @return<br />
	 */<br />
	public static String stream2string(InputStream is, String encode) {<br />
		if (is != null) {<br />
			try {<br />
				BufferedReader reader = new BufferedReader(new InputStreamReader(is, encode));<br />
				StringBuilder sb = new StringBuilder();<br />
				String line = null;<br />
				while ((line = reader.readLine()) != null) {<br />
					sb.append(line + “\n”);<br />
				}<br />
				is.close();<br />
				return sb.toString();<br />
			} catch (UnsupportedEncodingException e) {<br />
				e.printStackTrace();<br />
			} catch (IOException e) {<br />
				e.printStackTrace();<br />
			}<br />
		}<br />
		return “”;<br />
	}</p>
<p>	/**<br />
	 * InputStream转jsonarray<br />
	 * 此处在处理InputStream时所用的方法和上面一个函数不同，只是多列出一个可用方法，实际使用时，请考虑一下效率问题<br />
	 * 至于转成jsonarray的笨办法只是由于个人需求，接口也是自己写的，有十足把握不会导致出错，各位看官莫怪，轻易不要这样干<br />
	 * @param is<br />
	 * @return<br />
	 */<br />
	public static String stream2jarray(InputStream is) {<br />
		if (is != null) {<br />
			StringBuffer sb = new StringBuffer();<br />
			byte[] b = new byte[4096];<br />
			try {<br />
				for(int n;(n=is.read(b))!=-1;){<br />
					sb.append(new String(b,0,n));<br />
				}<br />
				is.close();<br />
				if(sb.charAt(0) == &#8216;{&#8216;){<br />
					return “["+sb.toString()+"]“;<br />
				}<br />
				else{<br />
					return sb.toString();<br />
				}<br />
			} catch (IOException e) {<br />
				e.printStackTrace();<br />
			}<br />
		}<br />
		return “”;<br />
	}</p>
<p>	/**<br />
	 * InputStream转jsonobject<br />
	 * 转jsonobject时同样使用了笨办法，轻易不要照我这样用<br />
	 * @param is<br />
	 * @return<br />
	 */<br />
	public static String stream2jobject(InputStream is) {<br />
		if (is != null) {<br />
			StringBuffer sb = new StringBuffer();<br />
			byte[] b = new byte[4096];<br />
			try {<br />
				for(int n;(n=is.read(b))!=-1;){<br />
					sb.append(new String(b,0,n));<br />
				}<br />
				is.close();<br />
				if (sb.charAt(0) == &#8216;[') {<br />
					return "{\"jarray\":" + sb.toString() + "}";<br />
				}<br />
				else {<br />
					return sb.toString();<br />
				}<br />
			} catch (IOException e) {<br />
				e.printStackTrace();<br />
			}<br />
		}<br />
		return "";<br />
	}</p>
<p>	public static String stream2string(InputStream is) {<br />
		return stream2string(is, "utf-8");<br />
	}</p>
<p>	/**<br />
	 * @param inStream<br />
	 * @return<br />
	 * @throws Exception<br />
	 */<br />
	public static byte[] stream2byte(InputStream inStream) throws Exception {<br />
		byte[] buffer = new byte[1024];<br />
		int len = -1;<br />
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();<br />
		while ((len = inStream.read(buffer)) != -1) {<br />
			outStream.write(buffer, 0, len);<br />
		}<br />
		byte[] data = outStream.toByteArray();<br />
		outStream.close();<br />
		inStream.close();<br />
		return data;<br />
	}<br />
}</p>
<p>[/java]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 05 月 08 日 -- <a href="http://sillydong.com/myjava/android-activity-finish.html" title="Android关闭所有Activity完全退出程序">Android关闭所有Activity完全退出程序</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-inputstream-string-json.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android计时器代码分享</title>
		<link>http://sillydong.com/myjava/android-develop-timer.html</link>
		<comments>http://sillydong.com/myjava/android-develop-timer.html#comments</comments>
		<pubDate>Mon, 19 Dec 2011 14:49:36 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[上传]]></category>
		<category><![CDATA[时间]]></category>
		<category><![CDATA[线程]]></category>
		<category><![CDATA[计时器]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=619</guid>
		<description><![CDATA[小生写了段时间android应用，做出了5个应用，积累了一些代码，不敢私藏，遂决定整理一下，与诸位看官分享。诸位要是觉得这代码太烂，效率太低，千万别省着口水，使劲吐槽。今天贴出最短的一段，计时器代码。 <a href="http://sillydong.com/myjava/android-develop-timer.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>小生写了段时间android应用，做出了5个应用，积累了一些代码，不敢私藏，遂决定整理一下，与诸位看官分享。诸位要是觉得这代码太烂，效率太低，千万别省着口水，使劲吐槽。今天贴出最短的一段，计时器代码。<span id="more-619"></span></p>
<p>在进行一些费时操作时，可以使用这个类来计时。比如上传操作，可以用这个来看上传一共花了多少时间，或者为线程计时什么的。代码如下：</p>
<p>[java]<br />
package czd.android.utils;</p>
<p>import android.util.Log;</p>
<p>/**<br />
 * @author Chen.Zhidong<br />
 *<br />
 */<br />
public class Timer {</p>
<p>	long startTime, stopTime;</p>
<p>	public Timer() {<br />
		start();<br />
	}</p>
<p>	/**<br />
	 * start Timer<br />
	 */<br />
	public void start() {<br />
		startTime = System.nanoTime();<br />
	}</p>
<p>	/**<br />
	 * stop Timer and print how long the action takes<br />
	 *<br />
	 * @param what<br />
	 */<br />
	public void stop(String what) {<br />
		stopTime = System.nanoTime();<br />
		long val = (stopTime &#8211; startTime) / 1000L;<br />
		Log.e(“TimeSpend”, what + “:” + val + “s”);<br />
		start();<br />
	}<br />
}</p>
<p>[/java]</p>
<p>最后stop之后又执行start是为了在多次提交时可以直接再次stop打印出从上次结束倒现在的时间。很简短的代码，觉得有用的可以收下，不是什么牛B代码，下期代码会精彩一点哦~</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 05 月 08 日 -- <a href="http://sillydong.com/myjava/android-activity-finish.html" title="Android关闭所有Activity完全退出程序">Android关闭所有Activity完全退出程序</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-develop-timer.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android手机上传图片代码</title>
		<link>http://sillydong.com/myjava/android-image-upload.html</link>
		<comments>http://sillydong.com/myjava/android-image-upload.html#comments</comments>
		<pubDate>Wed, 16 Nov 2011 01:23:17 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[上传]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[应用]]></category>
		<category><![CDATA[服务器]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=611</guid>
		<description><![CDATA[这段代码用于从android手机向服务器上传图片文件，非FTP方式，当然稍作修改就可以用于上传其它文件。各位看官可以根据自己需要进行适当修改。不足之处还请指出，谢谢！ <a href="http://sillydong.com/myjava/android-image-upload.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这段代码用于从android手机向服务器上传图片文件，非FTP方式，当然稍作修改就可以用于上传其它文件。各位看官可以根据自己需要进行适当修改。不足之处还请指出，谢谢！<span id="more-611"></span></p>
<p>[java]<br />
/**<br />
 * upload file by making a form and return whether file upload successfuly<br />
 *<br />
 * @author Chen.Zhidong<br />
 * @param params<br />
 * @param dirname<br />
 * @param filename<br />
 * @param link<br />
 * @return boolean whether file upload succeeded or failed<br />
 */<br />
public static boolean fileUpload(Map<string , String> params, String dirname, String filename, String link) {<br />
	try {<br />
		String BOUNDARY = “&#8212;”;<br />
		String MULTIPART_FORM_DATA = “Multipart/form-data”;<br />
		URL url = new URL(link);<br />
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();<br />
		conn.setDoInput(true);<br />
		conn.setDoOutput(true);<br />
		conn.setUseCaches(false);<br />
		conn.setRequestMethod(“POST”);<br />
		conn.setRequestProperty(“Connection”, “Keep-Alive”);<br />
		conn.setRequestProperty(“Charset”, “UTF-8&#8243;);<br />
		conn.setRequestProperty(“Content-Type”, MULTIPART_FORM_DATA + “;boundary=” + BOUNDARY);<br />
		DataOutputStream outStream = new DataOutputStream(conn.getOutputStream());<br />
		if (params != null &#038;&#038; !params.isEmpty()) {<br />
			StringBuilder sb = new StringBuilder();<br />
			for (Map.Entry</string><string , String> entry : params.entrySet()) {<br />
				sb.append(BOUNDARY);<br />
				sb.append(“\r\n”);<br />
				sb.append(“Content-Disposition: form-data; name=\”" + entry.getKey() + “\”\r\n\r\n”);<br />
				sb.append(entry.getValue());<br />
				sb.append(“\r\n”);<br />
			}<br />
			outStream.write(sb.toString().getBytes());<br />
		}<br />
		//此处用的是我自己写的一个读图片的函数，看官可以改成自己的获取文件到byte[]的函数<br />
		byte[] content = ImageUtil.readImageByte(dirname + &#8216;/&#8217; + filename);<br />
		StringBuilder split = new StringBuilder();<br />
		split.append(BOUNDARY);<br />
		split.append(“\r\n”);<br />
		split.append(“Content-Disposition: form-data;name=\”imgfile\”;filename=\”" + filename + “\”\r\n”);<br />
		split.append(“Content-Type: image/jpg\r\n”);<br />
		outStream.write(split.toString().getBytes());<br />
		outStream.write(content, 0, content.length);<br />
		outStream.write(“\r\n”.getBytes());<br />
		byte[] end_data = (BOUNDARY + “&#8211;\r\n”).getBytes();<br />
		outStream.write(end_data);<br />
		outStream.flush();<br />
		if (conn.getInputStream() != null) {<br />
			conn.disconnect();<br />
			return true;<br />
		}<br />
		else {<br />
			conn.disconnect();<br />
		}<br />
	}catch (IOException e) {<br />
		e.printStackTrace();<br />
	}<br />
	return false;<br />
}<br />
[/java]</string></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 04 月 04 日 -- <a href="http://sillydong.com/myjava/android-radiation-check.html" title="原创Android核辐射监测应用">原创Android核辐射监测应用</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-image-upload.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>通用Linux服务器备份打包脚本</title>
		<link>http://sillydong.com/myserver/tar-backup.html</link>
		<comments>http://sillydong.com/myserver/tar-backup.html#comments</comments>
		<pubDate>Tue, 23 Aug 2011 01:48:34 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[备份]]></category>
		<category><![CDATA[打包]]></category>
		<category><![CDATA[服务器备份]]></category>
		<category><![CDATA[清理]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=580</guid>
		<description><![CDATA[最近由于有需求，遂把原来的服务器打包备份脚本重写了一下，根据现有的情况做了很大调整。用tar.set文件进行备份配置。脚本主要的功能是将从远程服务器同步过来的文件打包放到预定的打包文件目录，同时把主从同步的数据库导出来也放到预置的目录。在打包文件保存目录会进行删除太旧的打包，保留每月1号和最近N天的打包文件，避免因为没用的备份文件过去占用了太大空间。针对数据库，在tar.set中特意设置了端口和socket的配置，为了方便使用非3306端口的情况。先看目录结构： [bash] /home/www/IP/www.xxx.com #同步过来的文件放在这个目录 /home/logs/ #打包日志存放此处 /home/backup/www/IP/ #打包的网站文件存放此处 /home/backup/mysql/IP/ #导出的mysql文件放在此处 [/bash] 下面是备份配置文件tar.set的内容，这个文件要放在需要备份的网站根目录下，即/home/www/IP/www.xxx.com/tar.set [bash] WWWNAME=www.xxx.com TARSET=daily &#124;&#124; weekly &#124;&#124; monthly OLDSET=5 days ago &#124;&#124; 2 weeks ago DBNAME=xxxxx DBPORT=3306 DBSOCKET=/tmp/mysql.sock SRCIP=123.123.123.123 [/bash] 主要的代码如下，看官如果有能提高一点效率的建议欢迎留言。现在很多读文件的，效率会低。 [bash] #!/bin/bash # By Chen Zhidong # http://sillydong.com &#8230; <a href="http://sillydong.com/myserver/tar-backup.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近由于有需求，遂把原来的服务器打包备份脚本重写了一下，根据现有的情况做了很大调整。<span style="color: #ff0000;">用tar.set文件进行备份配置</span>。脚本主要的功能是将从远程服务器同步过来的文件打包放到预定的打包文件目录，同时把主从同步的数据库导出来也放到预置的目录。<span style="color: #ff0000;">在打包文件保存目录会进行删除太旧的打包，保留每月1号和最近N天的打包文件，避免因为没用的备份文件过去占用了太大空间。针对数据库，在tar.set中特意设置了端口和socket的配置，为了方便使用非3306端口的情况。</span>先看目录结构：</p>
<p><span id="more-580"></span></p>
<p>[bash]<br />
/home/www/IP/www.xxx.com	#同步过来的文件放在这个目录<br />
/home/logs/	#打包日志存放此处<br />
/home/backup/www/IP/	#打包的网站文件存放此处<br />
/home/backup/mysql/IP/	#导出的mysql文件放在此处<br />
[/bash]</p>
<p>下面是备份配置文件tar.set的内容，<span style="color: #ff0000;">这个文件要放在需要备份的网站根目录下，即/home/www/IP/www.xxx.com/tar.set</span></p>
<p>[bash]<br />
WWWNAME=www.xxx.com<br />
TARSET=daily || weekly || monthly<br />
OLDSET=5 days ago || 2 weeks ago<br />
DBNAME=xxxxx<br />
DBPORT=3306<br />
DBSOCKET=/tmp/mysql.sock<br />
SRCIP=123.123.123.123<br />
[/bash]</p>
<p>主要的代码如下，看官如果有能提高一点效率的建议欢迎留言。现在很多读文件的，效率会低。</p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>#Begin<br />
#======================================================<br />
ROOTDIR=”/home/www”<br />
LOGDIR=”/home/logs”<br />
TARDIR=”/home/backup/www”<br />
SQLDIR=”/home/backup/mysql”<br />
BINDIR=”/usr/local/mysql/bin”</p>
<p>EXCLUDE=”.tar.gz .tar.bz2 .zip”</p>
<p>DAY_WEEK=”5&#8243;<br />
DAY_MONTH=”26&#8243;</p>
<p>DB_USER=”root”<br />
DB_PASS=”xxxxxx”<br />
DB_HOST=”localhost”</p>
<p>TAG=$(date +%Y%m%d)<br />
#======================================================<br />
readset(){<br />
#readset WWWNAME tarsetfile<br />
	grep $1 $2 | sed “s/$1=//”<br />
}</p>
<p>exclude(){<br />
#exclude directory<br />
	for ex in $EXCLUDE<br />
	do<br />
		exc=`ls $1 | grep $ex`<br />
		if [ -n $exc ];then<br />
			echo ${1}/${exc} >> exclude.tmp >> $LOGDIR/tarback_$TAG.log<br />
		fi<br />
	done<br />
}</p>
<p>clean(){<br />
#clean name filedir frequency tarset<br />
	oldset=`readset OLDSET $4`<br />
	case $3 in<br />
	daily)<br />
		FILELIST=`ls -l $2 | awk &#8216;{print $9}&#8217; | egrep “^$1_.*”`<br />
		for file in $FILELIST<br />
		do<br />
			old=$(date +%Y%m%d &#8211;date=”$oldset”)<br />
			mold=$(date +%m)<br />
			tim=`echo “$file” | sed “s/.*_\([0-9]*\).*/\1/”`<br />
			day=`expr substr $tim 7 2`<br />
			month=`expr substr $tim 5 2`<br />
			if [ $tim -le $old ];then<br />
				if [ "$day" = "01" -a "$month" = "$mold" ];then<br />
					echo “$file was left as No.1!” >> $LOGDIR/tarback_$TAG.log<br />
				else<br />
					echo “$file to be removed!” >> $LOGDIR/tarback_$TAG.log<br />
					rm -f $2/$file<br />
				fi<br />
			else<br />
				echo “$file was left!” >> $LOGDIR/tarback_$TAG.log<br />
			fi<br />
		done<br />
		;;<br />
	weekly)<br />
		FILELIST=`ls -l $2 | awk &#8216;{print $9}&#8217; | grep $1`<br />
		for file in $FILELIST<br />
		do<br />
			old=$(date +%Y%m%d &#8211;date=$oldset)<br />
			tim=`echo “$file” | sed “s/.*${1}_\([0-9]*\)..*/\1/”`<br />
			if [ $tim -le $old ];then<br />
				echo -e “$2/$file to be removed!” >> $LOGDIR/tarback_$TAG.log<br />
				rm -f $2/$file<br />
			else<br />
				echo “$file will be kept!” >> $LOGDIR/tarback_$TAG.log<br />
			fi<br />
		done<br />
		;;<br />
	monthly)<br />
		FILELIST=`ls -l $2 | awk &#8216;{print $9}&#8217; | grep $1`<br />
		for file in $FILELIST<br />
		do<br />
			old=$(date +%Y%m%d &#8211;date=$oldset)<br />
			tim=`echo “$file” | sed “s/.*${1}_\([0-9]*\)..*/\1/”`<br />
			if [ $tim -le $old ];then<br />
				echo -e “$2/$file to be removed!” >> $LOGDIR/tarback_$TAG.log<br />
				rm -f $2/$file<br />
			else<br />
				echo “$file will be kept!” >> $LOGDIR/tarback_$TAG.log<br />
			fi<br />
		done<br />
		;;<br />
	*)<br />
		echo “Error: Wrong Frepquency was sent to clean()!” >> $LOGDIR/tarback_$TAG.log<br />
		;;<br />
	esac<br />
}</p>
<p>dump(){<br />
#dump tarsetfile ip dbname<br />
	if [ -n $1 ];then<br />
		dbport=`readset DBPORT $1`<br />
		dbsocket=`readset DBSOCKET $1`<br />
		echo “Dumping ${3} ${dbport} ${dbsocket} &#8230;” >> $LOGDIR/tarback_$TAG.log<br />
		$BINDIR/mysqldump &#8211;opt $3 &#8211;user=$DB_USER &#8211;host=$DB_HOST &#8211;password=$DB_PASS -P $dbport -S $dbsocket > $SQLDIR/$2/${3}_${TAG}.sql<br />
		if [ "$?" = "0" ];then<br />
			echo “Dumping ${3} done!” >> $LOGDIR/tarback_$TAG.log<br />
		else<br />
			echo “***Dumping ${3} failed!***” >> $LOGDIR/tarback_$TAG.log<br />
		fi<br />
	else<br />
		echo “$1 has no database!” >> $LOGDIR/tarback_$TAG.log<br />
	fi<br />
}</p>
<p>tarfile(){<br />
#tarfile tarset ip frequency $dbname<br />
	srcdir=`echo “$1&#8243; | sed “s/\/tar.set$//”`<br />
	destfile=$TARDIR/$srcdir<br />
	echo “tar $srcdir to ${destfile}_$TAG.tar.bz2&#8243; >> $LOGDIR/tarback_$TAG.log</p>
<p>	exclude $srcdir<br />
	if [ -e $ROOTDIR/exclude.tmp ];then<br />
		tar jcPf ${destfile}_$TAG.tar.bz2 $srcdir &#8211;exclude-from=”$ROOTDIR/exclude.tmp”<br />
		rm -f $ROOTDIR/exclude.tmp<br />
	else<br />
		tar jcPf ${destfile}_$TAG.tar.bz2 $srcdir<br />
	fi<br />
	echo “tar $srcdir done!” >> $LOGDIR/tarback_$TAG.log</p>
<p>	tardir=$TARDIR/$2<br />
	wwwname=`readset WWWNAME $1`<br />
	echo “cleanning www $wwwname &#8230;” >> $LOGDIR/tarback_$TAG.log<br />
	clean $wwwname $tardir $3 $1</p>
<p>	sqldir=$SQLDIR/$2<br />
	echo “cleanning sql $4 &#8230;” >> $LOGDIR/tarback_$TAG.log<br />
	clean $4 $sqldir $3 $1<br />
}</p>
<p>#=================================================================</p>
<p>if [ `pwd` != "$ROOTDIR" ];then<br />
	cd $ROOTDIR<br />
fi</p>
<p>if [ -e $ROOTDIR/tarback_$(date +%Y%m%d --date="5 days ago").log ];then<br />
	rm -f $ROOTDIR/tarback_$(date +%Y%m%d &#8211;date=”5 days ago”).log<br />
fi</p>
<p>echo -e “Tarback work begin at $(date)&#8230;” >> $LOGDIR/tarback_$TAG.log</p>
<p>#list all *.set files in rsync directory<br />
LIST=`find ./ -maxdepth 3 -name tar.set`<br />
if [ -n $LIST ];then<br />
	echo “Nothing to do”<br />
	exit 1<br />
fi</p>
<p>for setfile in $LIST<br />
do<br />
	echo -e “&#8212;&#8212;&#8212;&#8211;\nUsing $setfile&#8230;” >> $LOGDIR/tarback_$TAG.log<br />
	ip=`readset SRCIP $setfile`<br />
	dbname=`readset DBNAME $setfile`<br />
	dump $setfile $ip $dbname<br />
	frequency=`readset TARSET $setfile`<br />
	case $frequency in<br />
	daily)<br />
		tarfile $setfile $ip $frequency $dbname<br />
		;;<br />
	weekly)<br />
        if [ $(date +%w) == $DAY_WEEK ];then<br />
			tarfile $setfile $ip $frequency $dbname<br />
		else<br />
			echo -e “TARSET is $frequency, $(date +%w) is not $DAY_WEEK.\n” >> $LOGDIR/tarback_$TAG.log<br />
		fi<br />
		;;<br />
	monthly)<br />
        if [ $(date +%d) == $DAY_MONTH ];then<br />
			tarfile $setfile $ip $frequency $dbname<br />
		else<br />
			echo -e “TARSET is $frequency, $(date +%d) is not $DAY_MONTH.\n” >> $LOGDIR/tarback_$TAG.log<br />
		fi<br />
		;;<br />
	*)<br />
		echo -e “Error: Wrong frequency set in $setfile\n” >> $LOGDIR/tarback_$TAG.log<br />
		;;<br />
	esac<br />
done</p>
<p>echo -e “Tarback work has been finished!” >> $LOGDIR/tarback_$TAG.log</p>
<p>exit 0<br />
#End<br />
[/bash]</p>
<p>欢迎留言提意见！</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html" title="用shell来为rsyncd增加删除站点配置">用shell来为rsyncd增加删除站点配置</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/new-shell-for-rsync.html" title="用rsync进行两机备份的shell脚本（更新）">用rsync进行两机备份的shell脚本（更新）</a></li><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/tar-backup.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>苹果系统显示隐藏文件切换脚本</title>
		<link>http://sillydong.com/myshell/dot-file-show-hide.html</link>
		<comments>http://sillydong.com/myshell/dot-file-show-hide.html#comments</comments>
		<pubDate>Fri, 22 Jul 2011 15:08:48 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[finder]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[苹果]]></category>
		<category><![CDATA[隐藏]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=575</guid>
		<description><![CDATA[初用苹果机，各种不习惯。幸好和Linux有几分相似。但是操作上差别就大了去了。因为经常需要操作隐藏文件，又不想整天看到一大堆带点的文件，所 以写了个小脚本，无聊之作，勿喷。用的还是Bash。我感觉应该有办法做个直接点击就能进行互相切换的操作，比如给Finder加个什么操作？下次研究出 来了再说。 <a href="http://sillydong.com/myshell/dot-file-show-hide.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>初用苹果机，各种不习惯。幸好和Linux有几分相似。但是操作上差别就大了去了。因为经常需要操作隐藏文件，又不想整天看到一大堆带点的文件，所 以写了个小脚本，无聊之作，勿喷。用的还是Bash。我感觉应该有办法做个直接点击就能进行互相切换的操作，比如给Finder加个什么操作？下次研究出 来了再说。先放代码：<span id="more-575"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# hideshow.sh<br />
if [ $# -lt 1 ];then<br />
	echo “usage hideshow.sh hide|show”<br />
	exit<br />
fi<br />
case $1 in<br />
show)<br />
	if [ `defaults read com.apple.finder AppleShowAllFiles` = "1" ];then<br />
		echo “Hide files already been shown, did nothing!”<br />
		exit<br />
	else<br />
		defaults write com.apple.finder AppleShowAllFiles -bool true<br />
		killall Finder<br />
		exit<br />
	fi<br />
	;;<br />
hide)<br />
	if [ `defaults read com.apple.finder AppleShowAllFiles` = "0" ];then<br />
		echo “Dot Files already been hided, did nothing!”<br />
		exit<br />
	else<br />
		defaults write com.apple.finder AppleShowAllFiles -bool false<br />
		killall Finder<br />
		exit<br />
	fi<br />
	;;<br />
*)<br />
	echo “usage hideshow.sh hide|show”<br />
	;;<br />
esac<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/clean-black-chain.html" title="分享一个Linux上清除黑链的脚本">分享一个Linux上清除黑链的脚本</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2010 年 09 月 26 日 -- <a href="http://sillydong.com/myshell/bash-operator.html" title="Bash脚本编程中的操作符简述">Bash脚本编程中的操作符简述</a></li><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/dot-file-show-hide.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android美化TabWidget详细代码</title>
		<link>http://sillydong.com/myjava/android-tabwidget.html</link>
		<comments>http://sillydong.com/myjava/android-tabwidget.html#comments</comments>
		<pubDate>Thu, 12 May 2011 14:08:10 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[tabhost]]></category>
		<category><![CDATA[tabwidget]]></category>
		<category><![CDATA[开发]]></category>
		<category><![CDATA[标签]]></category>
		<category><![CDATA[美化]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=553</guid>
		<description><![CDATA[Android默认的tabwidget是置顶的，有时放在下面比较好看，但是使用默认的tabwidget放在下面看上去效果非常不好看，由此对其美化一下。设置其背景，以及选中的tab和未被选中的tab差异化，同时去掉了烦人了白线，同时对被选中和未被选中的标签进行区别，效果还可以。看代码。 <a href="http://sillydong.com/myjava/android-tabwidget.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Android默认的tabwidget是置顶的，有时放在下面比较好看，但是使用默认的tabwidget放在下面看上去效果非常不好看，由此对其美化一下。设置其背景，以及选中的tab和未被选中的tab差异化，同时去掉了烦人了白线，同时对被选中和未被选中的标签进行区别，效果还可以。看代码。<span id="more-553"></span></p>
<div id="attachment_559" class="wp-caption aligncenter" style="width: 330px"><a rel="attachment wp-att-559" href="http://sillydong.com/myjava/android-tabwidget.html/attachment/device"><img class="size-full wp-image-559" title="Android-tabwidget" src="http://sillydong.com/wp-content/uploads/2011/05/device.png" alt="Android tabwidget美化效果图" width="320" height="480" /></a><p class="wp-caption-text">Android tabwidget美化效果图</p></div>
<p>预先准备好几个资源文件，然后在extends TabActivity的那个class中加进这个函数，找个地方调用它，就OK了。</p>
<p>[java]<br />
//记得先定义这几个变量<br />
private TabHost tabHost;<br />
private TabWidget tabWidget;<br />
Field mBottomLeftStrip;<br />
Field mBottomRightStrip;</p>
<p>public TabHost makeTab(){<br />
	if(this.tabHost == null){<br />
		tabHost = (TabHost)findViewById(android.R.id.tabhost);<br />
		tabWidget = (TabWidget)findViewById(android.R.id.tabs);<br />
		tabHost.setup();<br />
		tabHost.bringToFront();</p>
<p>		TabSpec nearby_tab = tabHost.newTabSpec(“nearby_tab”);<br />
		TabSpec history_tab = tabHost.newTabSpec(“history_tab”);<br />
		TabSpec about_tab = tabHost.newTabSpec(“about_tab”);</p>
<p>		nearby_tab.setIndicator(“first”,getResources().getDrawable(R.drawable.first)).setContent(new Intent(this,first.class));<br />
		history_tab.setIndicator(“second”,getResources().getDrawable(R.drawable.second)).setContent(new Intent(this,second.class));<br />
		about_tab.setIndicator(“third”,getResources().getDrawable(R.drawable.third)).setContent(new Intent(this,third.class));</p>
<p>		tabHost.addTab(nearby_tab);<br />
		tabHost.addTab(history_tab);<br />
		tabHost.addTab(about_tab);</p>
<p>		if (Integer.valueOf(Build.VERSION.SDK) <= 7) {<br />
			try {<br />
				mBottomLeftStrip = tabWidget.getClass().getDeclaredField ("mBottomLeftStrip");<br />
				mBottomRightStrip = tabWidget.getClass().getDeclaredField ("mBottomRightStrip");<br />
				if(!mBottomLeftStrip.isAccessible()) {<br />
					mBottomLeftStrip.setAccessible(true);<br />
				}<br />
				if(!mBottomRightStrip.isAccessible()){<br />
					mBottomRightStrip.setAccessible(true);<br />
				}<br />
				mBottomLeftStrip.set(tabWidget, getResources().getDrawable (R.drawable.linee));<br />
				mBottomRightStrip.set(tabWidget, getResources().getDrawable (R.drawable.linee));</p>
<p>			} catch (Exception e) {<br />
				e.printStackTrace();<br />
			}<br />
		} else {<br />
			try {<br />
				mBottomLeftStrip = tabWidget.getClass().getDeclaredField("mLeftStrip");<br />
				mBottomRightStrip = tabWidget.getClass().getDeclaredField("mRightStrip");<br />
				if (!mBottomLeftStrip.isAccessible()) {<br />
					mBottomLeftStrip.setAccessible(true);<br />
				}<br />
				if (!mBottomRightStrip.isAccessible()) {<br />
					mBottomRightStrip.setAccessible(true);<br />
				}<br />
				mBottomLeftStrip.set(tabWidget, getResources().getDrawable(R.drawable.linee));<br />
				mBottomRightStrip.set(tabWidget, getResources().getDrawable(R.drawable.linee));<br />
			} catch (Exception e) {<br />
				// TODO Auto-generated catch block<br />
				e.printStackTrace();<br />
			}<br />
		}</p>
<p>		for (int i =0; i <tabWidget.getChildCount(); i++) {</p>
<p>			final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);<br />
			tv.setTextColor(Color.WHITE);<br />
			View vvv = tabWidget.getChildAt(i);<br />
			if(tabHost.getCurrentTab()==i){<br />
				vvv.setBackgroundDrawable(getResources().getDrawable(R.drawable.focus));<br />
			}<br />
			else {<br />
				vvv.setBackgroundDrawable(getResources().getDrawable(R.drawable.unfocus));<br />
			}<br />
		}</p>
<p>		tabHost.setOnTabChangedListener(new OnTabChangeListener(){</p>
<p>			@Override<br />
			public void onTabChanged(String tabId) {<br />
			// TODO Auto-generated method stub<br />
			for (int i =0; i < tabWidget.getChildCount(); i++) {<br />
				View vvv = tabWidget.getChildAt(i);<br />
				if(tabHost.getCurrentTab()==i){<br />
					vvv.setBackgroundDrawable(getResources().getDrawable(R.drawable.focus));<br />
				}<br />
				else {<br />
					vvv.setBackgroundDrawable(getResources().getDrawable(R.drawable.unfocus));<br />
				}<br />
			}<br />
			}<br />
		});<br />
	}<br />
	else{<br />
		return tabHost;<br />
	}<br />
	return null;<br />
}<br />
[/java]</p>
<p>用到的布局xml文件内容如下：</p>
<p>[xml]<br />
<?xml version="1.0" encoding="utf-8"?><br />
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"<br />
   android:id="@android:id/tabhost"<br />
   android:layout_width="fill_parent"<br />
   android:layout_height="fill_parent"></p>
<p>   <LinearLayout<br />
  	  android:orientation="vertical"<br />
  	  android:layout_width="fill_parent"<br />
   	  android:layout_height="fill_parent"><br />
      <FrameLayout<br />
         android:id="@android:id/tabcontent"<br />
         android:layout_width="fill_parent"<br />
         android:layout_height="wrap_content"<br />
         android:layout_weight="1"><br />
      </FrameLayout><br />
      <TabWidget<br />
         android:id="@android:id/tabs"<br />
         android:layout_width="fill_parent"<br />
         android:layout_alignParentBottom="true"<br />
         android:layout_height="wrap_content"/><br />
	</LinearLayout><br />
</TabHost><br />
[/xml]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 04 日 -- <a href="http://sillydong.com/myjava/android-smsc.html" title="Android手机短信SMSC算法">Android手机短信SMSC算法</a></li><li>2011 年 12 月 26 日 -- <a href="http://sillydong.com/myjava/android-md5-base64-encode-decode.html" title="Android MD5加密类和Base64编解码类">Android MD5加密类和Base64编解码类</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-tabwidget.html/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Android关闭所有Activity完全退出程序</title>
		<link>http://sillydong.com/myjava/android-activity-finish.html</link>
		<comments>http://sillydong.com/myjava/android-activity-finish.html#comments</comments>
		<pubDate>Sun, 08 May 2011 02:26:50 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[activity]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[finish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[关闭]]></category>
		<category><![CDATA[堆栈]]></category>
		<category><![CDATA[完全退出]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=551</guid>
		<description><![CDATA[在做Android开发时，时常会发生在activity之间跳转后退出时会跳转回某个Activity的情况，通常是在退出程序时发生，导致不能完全退出程序。我网上搜了一下，有说法说这是Android系统activity堆栈的结果。有人提出了一些解决方法，我挑了一个最方便最通用的实现了一下，将所有建立的activity加进一个list，在需要程序结束时，finish所有list中的acitivity，共享出来，看下面代码。 <a href="http://sillydong.com/myjava/android-activity-finish.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>在做Android开发时，时常会发生在activity之间跳转后退出时会跳转回某个Activity的情况，通常是在退出程序时发生，导致不能完全退出程序。我网上搜了一下，有说法说这是Android系统activity堆栈的结果。有人提出了一些解决方法，我挑了一个最方便最通用的实现了一下，将所有建立的activity加进一个list，在需要程序结束时，finish所有list中的acitivity，共享出来，看下面代码。<span id="more-551"></span></p>
<p>[java]<br />
//建立一个public static的list用来放activity<br />
public static List activityList = new ArrayList();</p>
<p>//在每个activity建立的时候将这个activity加进list<br />
main.activityList.add(main.this);</p>
<p>//finish所有list中的activity<br />
public static void killall(){<br />
    int siz=activityList.size();<br />
    for(int i=0;i<siz;i++){<br />
        if(activityList.get(i)!=null){<br />
            activityList.get(i).finish();<br />
        }<br />
    }<br />
}<br />
[/java]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-activity-finish.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>用shell来为rsyncd增加删除站点配置</title>
		<link>http://sillydong.com/myshell/rsyncd-configure-shell.html</link>
		<comments>http://sillydong.com/myshell/rsyncd-configure-shell.html#comments</comments>
		<pubDate>Fri, 15 Apr 2011 06:45:52 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[rsyncd]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[同步]]></category>
		<category><![CDATA[备份]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=545</guid>
		<description><![CDATA[通常一个企业会用一台机子做备份机，其他机器的数据都备份到这台机器上，机器少还好，如果一次要增加的机器多了，那要增加配置就很麻烦。写了一个小脚本，能够增加和删除该服务器的配置。
原理是根据每台服务器的IP来设置一段配置，所以服务器上要备份到备份机上来也得做对应的配置。使用前要先看清配置，免得出了问题啊。 <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>通常一个企业会用一台机子做备份机，其他机器的数据都备份到这台机器上，机器少还好，如果一次要增加的机器多了，那要增加配置就很麻烦。写了一个小脚本，能够增加和删除该服务器的配置。</p>
<p>原理是根据每台服务器的IP来设置一段配置，所以服务器上要备份到备份机上来也得做对应的配置。使用前要先看清配置，免得出了问题啊。<span id="more-545"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# ./rsyncd.sh (add|del)IP<br />
# By Chen Zhidong<br />
# http://sillydong.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>CONFPATH=”/xxxxxxx”<br />
PASSPATH=”/xxxxxxx”</p>
<p>if [ $(id -u) != "0" ];then<br />
    echo “Error: You must be root to run this script!”<br />
    exit 1<br />
fi</p>
<p>if [ $# -lt 2 ]; then<br />
    echo “Syntax: ./rsyncd.sh (add|del) IP”<br />
    exit<br />
fi</p>
<p>case $1 in<br />
add)<br />
    read -p “Sure to add \”$2\” into $CONFPATH?(Y/n)” choice1<br />
    case $choice1 in<br />
        n|N)<br />
            echo “Didn&#8217;t add any thing!”<br />
        ;;<br />
        *)<br />
            mkdir /backup/vhosts/tars/${2}<br />
            mkdir /backup/vhosts/rsyncfiles/${2}<br />
            mkdir /backup/mysql/rsyncfiles/${2}</p>
<p>            #for db<br />
            echo “[${2}_db_lio]” >> $CONFPATH<br />
            echo “path = /backup/mysql/rsyncfiles/${2}” >> $CONFPATH<br />
            echo “uid = root” >> $CONFPATH<br />
            echo “gid = root” >> $CONFPATH<br />
            echo “read only = false” >> $CONFPATH<br />
            echo “ignore errors” >> $CONFPATH<br />
            echo “secrets file = $PASSPATH” >> $CONFPATH<br />
            echo -e “hosts allow = ${2}\n” >> $CONFPATH</p>
<p>            #for www<br />
            echo “[${2}_www_lio]” >> $CONFPATH<br />
            echo “path = /backup/vhosts/rsyncfiles/${2}” >> $CONFPATH<br />
            echo “uid = root” >> $CONFPATH<br />
            echo “gid = root” >> $CONFPATH<br />
            echo “read only = false” >> $CONFPATH<br />
            echo “ignore errors” >> $CONFPATH<br />
            echo “secrets file = $PASSPATH” >> $CONFPATH<br />
            echo -e “hosts allow = ${2}\n” >> $CONFPATH</p>
<p>            tail -n 18 $CONFPATH<br />
        ;;<br />
    esac<br />
;;<br />
del)<br />
    read -p “Sure to delete \”$2\” from $CONFPATH?(y/N)” choice2<br />
    case $choice2 in<br />
        y|Y)<br />
            CLEAN=0<br />
            until [ "$CLEAN"  = "1" ]<br />
            do<br />
                line=`grep “${2}_” $CONFPATH -n | awk -F: &#8216;{print $1}&#8217;`<br />
                if [ -n "$line" ];then<br />
                    del=`echo $line | sed &#8216;s/ .*//&#8217;`<br />
                    for k in 1 2 3 4 5 6 7 8 9<br />
                    do<br />
                        sed -i “$del d” $CONFPATH<br />
                        let “k++”<br />
                    done<br />
                else<br />
                    CLEAN=1<br />
                fi<br />
            done<br />
            echo “Delete configure data for ${2} finished!”<br />
        ;;<br />
        *)<br />
            echo “Didn&#8217;t do any change!”<br />
        ;;<br />
    esac<br />
;;<br />
*)<br />
    echo “You may use this script like this: ./rsyncd.sh (add|del) IP”<br />
;;<br />
esac</p>
<p>#End<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/new-shell-for-rsync.html" title="用rsync进行两机备份的shell脚本（更新）">用rsync进行两机备份的shell脚本（更新）</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/rsyncd-configure-shell.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>将html处理成xml的shell</title>
		<link>http://sillydong.com/myshell/shell-html-to-xml-handler.html</link>
		<comments>http://sillydong.com/myshell/shell-html-to-xml-handler.html#comments</comments>
		<pubDate>Fri, 15 Apr 2011 06:22:59 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[核辐射]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=535</guid>
		<description><![CDATA[前段时间纠结于应用数据处理的速度。问了一些java前辈，没得到什么好方法，倒是有位前辈说到的提醒了我：数据放到服务器上处理。无奈本人在服务器上写的最熟的还是shell，就放弃用php通过json来减少更多流量的想法，用shell脚本将网页源代码做成xml，这样一个文件就只有几KB了，速度也变得飞快，非常有效，分享出来。各位看官随便看看，主要是逻辑，如有更好的建议，欢迎留言。 附上应用的下载地址：辐射查询应用 应用汇下载页面 技术支持页面：原创Android核辐射监测应用 [bash] #!/bin/bash # By Chen Zhidong # http://sillydong.com # Email:njutczd+gmail.com PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH #Begin cd /xxxxxxxxxxxxxxxxxxxxxxxxxxxxx wget &#8211;output-document=hist.tmp -q http://xxxxxxxxxxxxxxxxxxxxxxxxxx > /dev/null echo -e “\n” > hist.xml fgrep “hh14&#8243; hist.tmp &#124; sed &#8216;s/.*a href=\”\.\([^"]*\).*\(2011.*0\).*/http:\/\/xxxxxxxxxxxxxxxxx\1\n\2/&#8217; &#124; awk &#8230; <a href="http://sillydong.com/myshell/shell-html-to-xml-handler.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>前段时间纠结于应用数据处理的速度。问了一些java前辈，没得到什么好方法，倒是有位前辈说到的提醒了我：数据放到服务器上处理。无奈本人在服务器上写的最熟的还是shell，就放弃用php通过json来减少更多流量的想法，用shell脚本将网页源代码做成xml，这样一个文件就只有几KB了，速度也变得飞快，非常有效，分享出来。各位看官随便看看，主要是逻辑，如有更好的建议，欢迎留言。</p>
<p>附上应用的下载地址：<span style="font-size: large;"><a href="http://www.yingyonghui.com/soft_detail_108000_0_10.html">辐射查询应用  应用汇下载页面</a></span></p>
<p>技术支持页面：<span style="font-size: large;"><a href="http://sillydong.com/myjava/android-radiation-check.html">原创Android核辐射监测应用</a></span><span id="more-535"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>#Begin<br />
cd /xxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />
wget &#8211;output-document=hist.tmp -q http://xxxxxxxxxxxxxxxxxxxxxxxxxx > /dev/null<br />
echo -e “<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<android>” > hist.xml<br />
fgrep “hh14&#8243; hist.tmp | sed &#8216;s/.*a href=\”\.\([^"]*\).*\(2011.*0\).*/<item><url>http:\/\/xxxxxxxxxxxxxxxxx\1<\/url>\n<time>\2<\/time><\/item>/&#8217; | awk &#8216;NR%3==1&#8242; | sed &#8216;s/></>\n</' >> hist.xml<br />
echo “</android>” >> hist.xml<br />
rm -f hist.tmp</p>
<p>HISTORYS=`grep “url” hist.xml | sed &#8216;s/<[^<>]*>//g&#8217;`<br />
i=0<br />
for hist in $HISTORYS<br />
do<br />
	wget &#8211;output-document=$i.tmp -q $hist >/dev/null<br />
	echo -e “<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<android>” > $i.xml<br />
	egrep “<[^/>]*>([^<]*)</[FS]" $i.tmp | sed '1,6d' > $i.tmp.tmp<br />
	linenu=0<br />
	while read line<br />
	do<br />
		mod=$(($linenu%5))<br />
		case $mod in<br />
		0)<br />
			echo $line | sed &#8216;s/.*<[^\/>]*>\([^<]*\)<\/[FS].*/<item>\n<city>\1<\/city>/&#8217; >> $i.xml<br />
			;;<br />
		1)<br />
			echo $line | sed &#8216;s/.*<[^\/>]*>\([^<]*\)<\/[FS].*/<range>\1<\/range>/&#8217; >> $i.xml<br />
			;;<br />
		2)<br />
			echo $line | sed &#8216;s/.*<[^\/>]*>\([^<]*\)<\/[FS].*/<average>\1<\/average>/&#8217; >> $i.xml<br />
			;;<br />
		3)<br />
			echo $line | sed &#8216;s/.*<[^\/>]*>\([^<]*\)<\/[FS].*/<standard>\1<\/standard>/&#8217; >> $i.xml<br />
			;;<br />
		4)<br />
			echo $line | sed &#8216;s/.*<[^\/>]*>\([^<]*\)<\/[FS].*/<result>\1<\/result>\n<\/item>/&#8217; >> $i.xml<br />
			;;<br />
		esac<br />
		linenu=$(($linenu+1))<br />
	done < $i.tmp.tmp<br />
	echo "</android>” >> $i.xml<br />
	rm -f $i.tmp.tmp $i.tmp<br />
	i=$(($i+1))<br />
done<br />
#End<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 04 月 04 日 -- <a href="http://sillydong.com/myjava/android-radiation-check.html" title="原创Android核辐射监测应用">原创Android核辐射监测应用</a></li><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2012 年 03 月 04 日 -- <a href="http://sillydong.com/myjava/android-smsc.html" title="Android手机短信SMSC算法">Android手机短信SMSC算法</a></li><li>2011 年 12 月 26 日 -- <a href="http://sillydong.com/myjava/android-md5-base64-encode-decode.html" title="Android MD5加密类和Base64编解码类">Android MD5加密类和Base64编解码类</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/shell-html-to-xml-handler.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>原创Android核辐射监测应用</title>
		<link>http://sillydong.com/myjava/android-radiation-check.html</link>
		<comments>http://sillydong.com/myjava/android-radiation-check.html#comments</comments>
		<pubDate>Sun, 03 Apr 2011 16:29:10 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[应用]]></category>
		<category><![CDATA[日本]]></category>
		<category><![CDATA[核泄漏]]></category>
		<category><![CDATA[核辐射]]></category>
		<category><![CDATA[监测]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=518</guid>
		<description><![CDATA[最近核辐射很是热门，趁着这个时候，为了方便大家看看自己所在城市附近的核辐射监测值，做了这个应用，花了5天时间独立完成。新手上路，BUG年年有，今年特别多。欢迎留言吐槽关于这个应用抽风的状况~ <a href="http://sillydong.com/myjava/android-radiation-check.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近核辐射很是热门，趁着这个时候，为了方便大家看看自己所在城市附近的核辐射监测值，做了这个应用，花了5天时间独立完成。新手上路，BUG年年有，今年特别多。欢迎留言吐槽关于这个应用抽风的状况~</p>
<p><span style="font-size: large;">下载链接：<a title="核辐射应用" href="http://www.yingyonghui.com/soft_detail_108000_0_10.html">核辐射应用</a>，猛击之！最低支持1.6版本固件。</span></p>
<p><span id="more-518"></span></p>
<div id="attachment_507" class="wp-caption aligncenter" style="width: 330px"><a href="http://sillydong.com/wp-content/uploads/2011/04/1.png"><img class="size-full wp-image-507" title="第一屏" src="http://sillydong.com/wp-content/uploads/2011/04/1.png" alt="第一屏" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/2.png"><img class="aligncenter size-full wp-image-508" title="第二屏" src="http://sillydong.com/wp-content/uploads/2011/04/2.png" alt="" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/3.png"><img class="aligncenter size-full wp-image-509" title="历史数据" src="http://sillydong.com/wp-content/uploads/2011/04/3.png" alt="" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/4.png"><img class="aligncenter size-full wp-image-510" title="城市列表" src="http://sillydong.com/wp-content/uploads/2011/04/4.png" alt="" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/5.png"><img class="aligncenter size-full wp-image-511" title="城市信息" src="http://sillydong.com/wp-content/uploads/2011/04/5.png" alt="" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/6.png"><img class="aligncenter size-full wp-image-512" title="辐射知识" src="http://sillydong.com/wp-content/uploads/2011/04/6.png" alt="" width="320" height="480" /></a><a href="http://sillydong.com/wp-content/uploads/2011/04/7.png"><img class="aligncenter size-full wp-image-513" title="小知识" src="http://sillydong.com/wp-content/uploads/2011/04/7.png" alt="" width="320" height="480" /></a><p class="wp-caption-text">界面截图</p></div>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-radiation-check.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Android获取网页数据的方法总结</title>
		<link>http://sillydong.com/myjava/android-http-methods.html</link>
		<comments>http://sillydong.com/myjava/android-http-methods.html#comments</comments>
		<pubDate>Mon, 21 Feb 2011 11:34:53 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[参数]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=492</guid>
		<description><![CDATA[本文总结了三种获取网页数据的代码，是自己在用的时候随手整理出来的。此处仅贴出函数段，不贴出import了，用的时候可以用eclipse自动import一下就行了。函数的详细用途描述请看代码中注释。调用的时候请对应函数需要的参数。 <a href="http://sillydong.com/myjava/android-http-methods.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>本文总结了三种获取网页数据的代码，是自己在用的时候随手整理出来的。此处仅贴出函数段，不贴出import了，用的时候可以用eclipse自动import一下就行了。函数的详细用途描述请看代码中注释。调用的时候请对应函数需要的参数。<span id="more-492"></span></p>
<p>[java]<br />
    //第一种<br />
    /**获取参数(ArrayList<NameValuePair> nameValuePairs,String url)后post给远程服务器<br />
     * 将获得的返回结果(String)返回给调用者<br />
     * 本函数适用于查询数量较少的时候<br />
     * Chen.Zhidong<br />
     * 2011-02-15*/<br />
    public String posturl(ArrayList<NameValuePair> nameValuePairs,String url){<br />
        String result = “”;<br />
        String tmp= “”;<br />
        InputStream is = null;<br />
        try{<br />
            HttpClient httpclient = new DefaultHttpClient();<br />
            HttpPost httppost = new HttpPost(url);<br />
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));<br />
            HttpResponse response = httpclient.execute(httppost);<br />
            HttpEntity entity = response.getEntity();<br />
            is = entity.getContent();<br />
        }catch(Exception e){<br />
            return “Fail to establish http connection!”;<br />
        }</p>
<p>        try{<br />
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,”utf-8&#8243;));<br />
            StringBuilder sb = new StringBuilder();<br />
            String line = null;<br />
            while ((line = reader.readLine()) != null) {<br />
                sb.append(line + “\n”);<br />
            }<br />
            is.close();</p>
<p>            tmp=sb.toString();<br />
        }catch(Exception e){<br />
            return “Fail to convert net stream!”;<br />
        }</p>
<p>        try{<br />
            JSONArray jArray = new JSONArray(tmp);<br />
            for(int i=0;i<jArray.length();i++){<br />
                JSONObject json_data = jArray.getJSONObject(i);<br />
                Iterator<?> keys=json_data.keys();<br />
                while(keys.hasNext()){<br />
                    result += json_data.getString(keys.next().toString());<br />
                }<br />
            }<br />
        }catch(JSONException e){<br />
            return “The URL you post is wrong!”;<br />
        }</p>
<p>        return result;<br />
    }</p>
<p>    //第二种<br />
    /**获取参数指定的网页代码，将其返回给调用者，由调用者对其解析<br />
     * 返回String<br />
     * Chen.Zhidong<br />
     * 2011-02-15*/<br />
    public String posturl(String url){<br />
        InputStream is = null;<br />
        String result = “”;</p>
<p>        try{<br />
            HttpClient httpclient = new DefaultHttpClient();<br />
            HttpPost httppost = new HttpPost(url);<br />
            HttpResponse response = httpclient.execute(httppost);<br />
            HttpEntity entity = response.getEntity();<br />
            is = entity.getContent();<br />
        }catch(Exception e){<br />
            return “Fail to establish http connection!”+e.toString();<br />
        }</p>
<p>        try{<br />
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,”utf-8&#8243;));<br />
            StringBuilder sb = new StringBuilder();<br />
            String line = null;<br />
            while ((line = reader.readLine()) != null) {<br />
                sb.append(line + “\n”);<br />
            }<br />
            is.close();</p>
<p>            result=sb.toString();<br />
        }catch(Exception e){<br />
            return “Fail to convert net stream!”;<br />
        }</p>
<p>        return result;<br />
    }</p>
<p>    //第三种<br />
    /**获取指定地址的网页数据<br />
     * 返回数据流<br />
     * Chen.Zhidong<br />
     * 2011-02-18*/<br />
    public InputStream streampost(String remote_addr){<br />
        URL infoUrl = null;<br />
        InputStream inStream = null;<br />
        try {<br />
            infoUrl = new URL(remote_addr);<br />
            URLConnection connection = infoUrl.openConnection();<br />
            HttpURLConnection httpConnection = (HttpURLConnection)connection;<br />
            int responseCode = httpConnection.getResponseCode();<br />
            if(responseCode == HttpURLConnection.HTTP_OK){<br />
                inStream = httpConnection.getInputStream();<br />
            }<br />
        } catch (MalformedURLException e) {<br />
            // TODO Auto-generated catch block<br />
            e.printStackTrace();<br />
        } catch (IOException e) {<br />
            // TODO Auto-generated catch block<br />
            e.printStackTrace();<br />
        }<br />
        return inStream;<br />
    }</p>
<p>[/java]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 12 月 23 日 -- <a href="http://sillydong.com/myjava/android-url-construct.html" title="Android URL链接生成函数">Android URL链接生成函数</a></li><li>2011 年 12 月 21 日 -- <a href="http://sillydong.com/myjava/android-sqlite-database.html" title="Android数据库操作类，超实用！">Android数据库操作类，超实用！</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li><li>2011 年 12 月 19 日 -- <a href="http://sillydong.com/myjava/android-develop-timer.html" title="Android计时器代码分享">Android计时器代码分享</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myjava/android-http-methods.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>我的Nagios安装配置笔记</title>
		<link>http://sillydong.com/myserver/my-nagios-configuration-notes.html</link>
		<comments>http://sillydong.com/myserver/my-nagios-configuration-notes.html#comments</comments>
		<pubDate>Thu, 10 Feb 2011 11:19:50 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[nrpe]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[监控]]></category>
		<category><![CDATA[配置]]></category>
		<category><![CDATA[集群]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=469</guid>
		<description><![CDATA[部门里负责运维的只有我一个人，所以服务器出了任何问题都得由我来处理，为了及时处理各种无法预料的问题，就借Nagios搭建了一个服务器集群监控平台。
以前用的是一个php自己写的，不稳定，误报率非常高，考虑到以后集群规模会比较大，国内网络条件也不是很好，所以做了这个平台来管理，明显减少了误报，什么原因出现什么样的报警也一清二楚，很方面。总结了一下安装配置的过程，放博客上与大家分享。文中不正之处，欢迎留言指出！有任何问题也可以留言提问。 <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>部门里负责运维的只有我一个人，所以服务器出了任何问题都得由我来处理，为了及时处理各种无法预料的问题，就借Nagios搭建了一个服务器集群监控平台。</p>
<p>以前用的是一个php自己写的，不稳定，误报率非常高，考虑到以后集群规模会比较大，国内网络条件也不是很好，所以做了这个平台来管理，明显减少了误报，什么原因出现什么样的报警也一清二楚，很方面。总结了一下安装配置的过程，放博客上与大家分享。文中不正之处，欢迎留言指出！有任何问题也可以留言提问。<span id="more-469"></span></p>
<p><strong>一、安装前信息收集</strong></p>
<p>首先确定一下相关变量<br />
查看Apache指定的CGI目录，在Apache安装目录下的bin目录中，执行<br />
[bash]./suexec -V[/bash]<br />
查看AP_DOC_ROOT项，这项配置的路径就是我们要将nagios安装到的目录，这个路径涉及到CGI的安全问题，在多次尝试之后我总结出来，不要尝试在编译apache时指定suexec的路径了，我这儿没用，还是干脆直接用默认的好了。此处以本机的/usr/local/apache2/htdocs/nagios为例<br />
查看Apache使用的用户<br />
[bash]grep ^User &#8211;after-contex=1 httpd.conf[/bash]<br />
此处以本机的www为例</p>
<p><strong>二、安装过程</strong></p>
<p>解压<br />
[bash]tar xzvf nagios-$version.tar.gz[/bash]<br />
编译安装<br />
[bash]./configure &#8211;prefix=/usr/local/apache2/htdocs/nagios &#8211;with-nagios-user=www &#8211;with-nagios-group=www &#8211;with-command-user=www &#8211;with-command-group=www &#8211;with-gd-lib=/usr/local/gd2/lib &#8211;with-gd-inc=/usr/local/gd2/include &#8211;with-init-dir=/etc/init.d &#8211;with-httpd-conf=/usr/local/apache2/conf/extra<br />
make all<br />
make install<br />
make install-commandmode<br />
make install-config<br />
make install-init[/bash]<br />
列目录<br />
[bash]ls /usr/local/apache2/htdocs/nagios/[/bash]<br />
查看是否有bin、etc、include、libexec、sbin、share、var这几个目录，有则说明nagios已经正常安装好了。</p>
<p>下面安装插件<br />
[bash]tar xzvf nagios-plugins-$version.tar.gz[/bash]<br />
编译安装<br />
[bash]./configure &#8211;prefix=/usr/local/apache2/htdocs/nagios &#8211;with-mysql=/usr/local/mysql &#8211;with-libiconv-prefix=/usr/local<br />
make<br />
make install[/bash]<br />
列目录<br />
[bash]ls /usr/local/apache2/htdocs/nagios/libexec[/bash]<br />
看到很多check_xxxx说明安装成功了。</p>
<p>到此Nagios需要安装的都安装好了，接下来就是配置了，见下页。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html" title="WordPress MU切实可用的nginx rewrite规则">WordPress MU切实可用的nginx rewrite规则</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2011 年 01 月 31 日 -- <a href="http://sillydong.com/myserver/apache-prefork-worker-optimize.html" title="Apache prefork和worker性能调优说明">Apache prefork和worker性能调优说明</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/my-nagios-configuration-notes.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>服务器服务监测脚本（更新）</title>
		<link>http://sillydong.com/myserver/new-service-monitor-shell.html</link>
		<comments>http://sillydong.com/myserver/new-service-monitor-shell.html#comments</comments>
		<pubDate>Thu, 10 Feb 2011 07:33:12 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[服务]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[监控]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[运维]]></category>
		<category><![CDATA[重启]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=465</guid>
		<description><![CDATA[上一回发布了<a href="http://sillydong.com/myserver/service-monitor-shell.html" target="_blank">服务器监控脚本</a>，这是该脚本的新版。此次更新内容包括：
1、添加了PATH处理，防止crontab执行脚本失败
2、精简了部分变量
3、添加了NRPE进程的监控
有参考上一版本脚本的朋友如有需要，可参照更新一下。 <a href="http://sillydong.com/myserver/new-service-monitor-shell.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>上一回发布了<a href="http://sillydong.com/myserver/service-monitor-shell.html" target="_blank">服务器监控脚本</a>，这是该脚本的新版。此次更新内容包括：</p>
<p>1、添加了PATH处理，防止crontab执行脚本失败<br />
2、精简了部分变量<br />
3、添加了NRPE进程的监控</p>
<p>有参考上一版本脚本的朋友如有需要，可参照更新一下。<span id="more-465"></span></p>
<p>脚本内容如下：</p>
<p>[bash]<br />
#!/bin/bash<br />
#    service &#8211;> name to test<br />
#    apache &#8211;> apache|apache2|http|httpd<br />
#    nginx &#8211;> nginx<br />
#    mysql &#8211;> mysql|mysqld<br />
#    php-cgi &#8211;> php-cgi<br />
#    vsftpd &#8211;> vsftp|vsftpd<br />
#    pure-ftpd &#8211;> pure-ftp|pure-ftpd<br />
#    apache-tomcat &#8211;> java<br />
#    nrpe &#8211;> nrpe<br />
# Set the service name you want to test and its max number of processes first.<br />
# Don&#8217;t forget to check the bin path for each service.<br />
# By Chen.Zhidong<br />
# http://sillydong.com</p>
<p>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH</p>
<p>SERVICE=”httpd mysqld vsftpd nrpe”<br />
SERVICE_MAX=(70 5 5 1)</p>
<p>LOGPATH=”/root”<br />
APACHE_PATH=”/usr/local/apache2&#8243;<br />
NGINX_PATH=”/usr/local/nginx”<br />
PHP_PATH=”/usr/local/php”<br />
TOMCAT_PATH=”/usr/local/apache-tomcat-6.0.26&#8243;<br />
PURE_PATH=”/usr/local/pureftpd”<br />
NRPE_PATH=”/usr/local/nagios”<br />
i=0</p>
<p>if [ -e $LOGPATH/restart.log ]<br />
then<br />
    tail -n 40 $LOGPATH/restart.log > $LOGPATH/restart.tmp<br />
    rm -rf $LOGPATH/restart.log<br />
    mv $LOGPATH/restart.tmp $LOGPATH/restart.log<br />
fi</p>
<p>for serv in $SERVICE<br />
do<br />
    counter=0<br />
    counter=`ps -A | grep “$serv” | wc -l`</p>
<p>    if [ $counter -eq 0 ];then<br />
        echo “$serv is off at $(date), starting&#8230;” >> $LOGPATH/restart.log<br />
        case $serv in<br />
            apache*|http*)<br />
                #echo “apache start”<br />
                $APACHE_PATH/bin/apachectl restart >> $LOGPATH/restart.log<br />
                ;;<br />
            nginx)<br />
                #echo “nginx start”<br />
                $NGINX_PATH/sbin/nginx -s reopen >> $LOGPATH/restart.log<br />
                ;;<br />
            mysql*)<br />
                #echo “mysql start”<br />
                #按照一般情况，在搭建服务器时就应该按照统一标准，此处可以按照实际情况修改一下<br />
                if [ -e /etc/init.d/mysqld ];then<br />
                    /etc/init.d/mysqld restart >> $LOGPATH/restart.log<br />
                else<br />
                    /etc/init.d/mysql restart >> $LOGPATH/restart.log<br />
                fi<br />
                ;;<br />
            php-cgi)<br />
                #echo “php-cgi start”<br />
                $PHP_PATH/sbin/php-fpm restart >> $LOGPATH/restart.log<br />
                ;;<br />
            vsftp*)<br />
                #echo “vsftpd start”<br />
                /etc/init.d/vsftpd restart >> $LOGPATH/restart.log<br />
                ;;<br />
            pure-ftp*)<br />
                #echo “pureftpd start”<br />
                $PURE_PATH/sbin/pure-ftpd -B >> $LOGPATH/restart.log<br />
                ;;<br />
            java*)   #apache-tomcat<br />
                #echo “tomcat start”<br />
                $TOMCAT_PATH/bin/startup.sh >> $LOGPATH/restart.log<br />
                ;;<br />
            nrpe)<br />
                #echo “nrpe start”<br />
                $NRPE/bin/nrpe -c $NRPE/etc/nrpe.cfg<br />
                ;;<br />
            *)<br />
                echo “Wrong service name while starting&#8230;” >> $LOGPATH/restart.log<br />
                ;;<br />
        esac<br />
    else<br />
        echo “$serv is on at $(date), next service&#8230;” >> $LOGPATH/restart.log<br />
    fi</p>
<p>    if [ $counter -gt ${SERVICE_MAX[i]} ];then<br />
        echo “$(date), too many $serv, needs to restart&#8230;” >> $LOGPATH/restart.log<br />
        case $serv in<br />
            apache*|http*)<br />
                #echo “apache restart”<br />
                $APACHE_PATH/bin/apachectl restart >> $LOGPATH/restart.log<br />
                ;;<br />
            nginx)<br />
                #echo “nginx restart”<br />
                $NGINX_PATH/sbin/nginx -s reload >> $LOGPATH/restart.log<br />
                ;;<br />
            mysql*)<br />
                #echo “mysql restart”<br />
                if [ -e /etc/init.d/mysqld ];<br />
                then<br />
                    /etc/init.d/mysqld restart >> $LOGPATH/restart.log<br />
                else<br />
                    /etc/init.d/mysql restart >> $LOGPATH/restart.log<br />
                fi<br />
                ;;<br />
            php-cgi)<br />
                #echo “php-cgi restart”<br />
                $PHP_PATH/sbin/php-fpm restart >> $LOGPATH/restart.log<br />
                ;;<br />
            vsftp*)<br />
                #echo “vsftpd restart”<br />
                /etc/init.d/vsftp* restart >> $LOGPATH/restart.log<br />
                ;;<br />
            pure-ftp*)<br />
                #echo “pureftpd restart”<br />
                $PURE_PATH/sbin/pure-ftpd -B >> $LOGPATH/restart.log<br />
                ;;<br />
            java*)   #apache-tomcat<br />
                #echo “tomcat restart”<br />
                $TOMCAT_PATH/bin/startup.sh >> $LOGPATH/restart.log<br />
                ;;<br />
            nrpe)<br />
                #echo “nrpe start”<br />
                killall nrpe<br />
                $NRPE/bin/nrpe -c $NRPE/etc/nrpe.cfg -d<br />
                ;;<br />
            *)<br />
                echo “Warning: Wrong service name while restartiing&#8230;”  >> $LOGPATH/restart.log<br />
                ;;<br />
        esac<br />
    fi<br />
    let “i++”<br />
done</p>
<p>exit 0</p>
<p>#End</p>
<p>[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/new-service-monitor-shell.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>我的iptables总结</title>
		<link>http://sillydong.com/myserver/iptables-rules-summary.html</link>
		<comments>http://sillydong.com/myserver/iptables-rules-summary.html#comments</comments>
		<pubDate>Wed, 09 Feb 2011 15:08:26 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[FORWARD]]></category>
		<category><![CDATA[INPUT]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[OUTPUT]]></category>
		<category><![CDATA[safe]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[防火墙]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=448</guid>
		<description><![CDATA[iptables是个好东西，但是各种规则对于刚上手的朋友来说很不友好，一开始会摸不着头脑。傻东经过一段时间的研究，终于摸着点门道，不敢私藏，更怕忘记，因此写下此文，与大家分享。本文中的内容是终端下输的命令，不是/etc/sysconfig/iptables中的内容。第一页为概略介绍，第二页为详细规则演示，文中代码若有不正之处，欢迎留言指出！ <a href="http://sillydong.com/myserver/iptables-rules-summary.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>iptables是个好东西，但是各种规则对于刚上手的朋友来说很不友好，一开始会摸不着头脑。傻东经过一段时间的研究，终于摸着点门道，不敢私藏，更怕忘记，因此写下此文，与大家分享。本文中的内容是终端下输的命令，不是/etc/sysconfig/iptables中的内容。<strong>第一页为概略介绍，第二页为详细规则演示</strong>，文中代码若有不正之处，欢迎留言指出！<span id="more-448"></span></p>
<p><strong>说明：</strong>文中“|”表示“或”</p>
<p><strong>对iptables操作的一般过程如下：</strong></p>
<p>列出iptable内容</p>
<p>[bash]iptables -L -n[/bash]</p>
<p>清除预设表filter中的所有规则链的规则</p>
<p>[bash]iptables -F[/bash]</p>
<p>清除预设表filter中使用者自定链中的规则</p>
<p>[bash]iptables -X[/bash]</p>
<p>修改规则，下面会有详细介绍</p>
<p>保存iptables中规则</p>
<p>[bash]<br />
service iptables save<br />
/etc/init.d/iptables save<br />
[/bash]</p>
<p>重启iptables服务</p>
<p>[bash]<br />
service iptables restart<br />
/etc/init.d/iptables restart<br />
[/bash]</p>
<p><strong>iptables规则介绍如下：</strong></p>
<p>参数说明：</p>
<p>[bash]<br />
INPUT	&#8211;dport -s<br />
OUTPUT	&#8211;sport -d<br />
-d	IP或IP段<br />
-s	IP或IP段<br />
-p	匹配TCP/UDP/ICMP，可使用相应的整数值，ICMP是1，TCP是6，UDP是17，缺省设置ALL是0，协议列表以英文逗号分隔，可以以“!”取反<br />
-i	输入接口<br />
-o	输出接口<br />
[/bash]</p>
<p>添加规则</p>
<p>[bash]<br />
#INPUT/OUTPUT链<br />
iptables -A INPUT|OUTPUT -s 源IP -d 目的IP -p tcp|udp|icmp &#8211;sport 源端口 &#8211;dport 目的端口 -j ACCEPT|DROP<br />
#FORWARD链<br />
iptables -A FORWARD -i 输入接口 -o 输出接口 -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT|DROP<br />
#NAT表<br />
iptables -t nat -A PREROUTING -i 输入接口 -s 源IP -d 目的IP &#8211;sport 源端口 &#8211;dport 目的端口 -j ACCEPT|DROP<br />
[/bash]</p>
<p>删除规则</p>
<p>[bash]<br />
#INPUT/OUTPUT链<br />
iptables -D INPUT|OUTPUT -s 源IP -d 目的IP -p tcp|udp|icmp &#8211;dport 端口 -j ACCEPT|DROP<br />
#FORWARD链<br />
iptables -D FORWARD -i 输入接口 -o 输出接口 -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT|DROP<br />
[/bash]</p>
<p>概略介绍结束，详细规则请看下页</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/linux-tomcat-memory.html" title="Linux下调整Tomcat内存设置">Linux下调整Tomcat内存设置</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/new-shell-for-rsync.html" title="用rsync进行两机备份的shell脚本（更新）">用rsync进行两机备份的shell脚本（更新）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/iptables-rules-summary.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Apache prefork和worker性能调优说明</title>
		<link>http://sillydong.com/myserver/apache-prefork-worker-optimize.html</link>
		<comments>http://sillydong.com/myserver/apache-prefork-worker-optimize.html#comments</comments>
		<pubDate>Mon, 31 Jan 2011 15:16:03 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[prefork]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[worker]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[性能]]></category>
		<category><![CDATA[服务器]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=442</guid>
		<description><![CDATA[最近有几台服务器有历史遗留问题，查日志，一个个查，查出问题，归根结底还是在apache性能方面。一开始对Apache的prefork和eorker模块不是很清楚，特地查了一下资料，调整之后果然好多了。特地整理了一下，记录在此，与君分享。 <a href="http://sillydong.com/myserver/apache-prefork-worker-optimize.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近有几台服务器有历史遗留问题，查日志，一个个查，查出问题，归根结底还是在apache性能方面。一开始对Apache的prefork和eorker模块不是很清楚，特地查了一下资料，调整之后果然好多了。特地整理了一下，记录在此，与君分享。<span id="more-442"></span></p>
<p><strong>prefork模式配置详解</strong></p>
<p>[bash]<br />
<IfModule mpm_prefork_module><br />
    ServerLimit 256<br />
    StartServers 5<br />
    MinSpareServers 5<br />
    MaxSpareServers 10<br />
    MaxClients 256<br />
    MaxRequestsPerChild 1000<br />
</IfModule><br />
[/bash]</p>
<p><strong>ServerLimit</strong></p>
<p>默认的MaxClient最大是256个线程,如果想设置更大的值，就的加上ServerLimit这个参数。20000是ServerLimit这个参数的最大值。如果需要更大，则必须编译apache,此前都是不需要重新编译Apache。</p>
<p>生效前提：必须放在其他指令的前面</p>
<p><strong>StartServers</strong></p>
<p>指定服务器启动时建立的子进程数量，prefork默认为5。</p>
<p><strong>MinSpareServers</strong></p>
<p>指定空闲子进程的最小数量，默认为5。如果当前空闲子进程数少于MinSpareServers ，那么Apache将以最大每秒一个的速度产生新的子进程。此参数不要设的太大。</p>
<p><strong>MaxSpareServers</strong></p>
<p>设置空闲子进程的最大数量，默认为10。如果当前有超过MaxSpareServers数量的空闲子进程，那么父进程将杀死多余的子进程。此参数不要设的太大。如果你将该指令的值设置为比MinSpareServers小，Apache将会自动将其修改成”MinSpareServers+1″。</p>
<p><strong>MaxClients</strong></p>
<p>限定同一时间客户端最大接入请求的数量(单个进程并发线程数)，默认为256。任何超过MaxClients限制的请求都将进入等候队列,一旦一个链接被释放，队列中的请求将得到服务。要增大这个值，你必须同时增大ServerLimit。</p>
<p><strong>MaxRequestsPerChild</strong></p>
<p>每个子进程在其生存期内允许伺服的最大请求数量，默认为10000.到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为”0″，子进程将永远不会结束。将MaxRequestsPerChild设置成非零值有两个好处：</p>
<p>1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。</p>
<p>2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。</p>
<p><strong>worker模式配置详解</strong></p>
<p>[bash]<br />
<IfModule mpm_worker_module><br />
    StartServers 2<br />
    MaxClients 150<br />
    MinSpareThreads 25<br />
    MaxSpareThreads 75<br />
    ThreadsPerChild 25<br />
    MaxRequestsPerChild 1000<br />
</IfModule><br />
[/bash]</p>
<p>StartServers</p>
<p>服务器启动时建立的子进程数，默认值是”3″。</p>
<p><strong>MaxClients</strong></p>
<p>允许同时伺服的最大接入请求数量(最大线程数量)。任何超过MaxClients限制的请求都将进入等候队列。默认值是”400″,16(ServerLimit)乘以25(ThreadsPerChild)的结果。因此要增加MaxClients的时候，你必须同时增加ServerLimit的值。</p>
<p><strong>MinSpareThreads</strong></p>
<p>最小空闲线程数,默认值是”75″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太少，子进程将产生新的空闲线程。</p>
<p><strong>MaxSpareThreads</strong></p>
<p>设置最大空闲线程数。默认值是”250″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太多，子进程将杀死多余的空闲线程。MaxSpareThreads的取值范围是有限制的。Apache将按照如下限制自动修正你设置的值：worker要求其大于等于MinSpareThreads加上ThreadsPerChild的和。</p>
<p><strong>ThreadsPerChild</strong></p>
<p>每个子进程建立的常驻的执行线程数。默认值是25。子进程在启动时建立这些线程后就不再建立新的线程了。</p>
<p><strong>MaxRequestsPerChild</strong></p>
<p>设置每个子进程在其生存期内允许伺服的最大请求数量。到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为”0″，子进程将永远不会结束。将MaxRequestsPerChild设置成非零值有两个好处：</p>
<p>1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。</p>
<p>2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。</p>
<p>注意对于KeepAlive链接，只有第一个请求会被计数。事实上，它改变了每个子进程限制最大链接数量的行为。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2011 年 11 月 16 日 -- <a href="http://sillydong.com/myjava/android-image-upload.html" title="Android手机上传图片代码">Android手机上传图片代码</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/apache-prefork-worker-optimize.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python笔记——数字类型的几个函数</title>
		<link>http://sillydong.com/mypython/functions-of-digital-in-python.html</link>
		<comments>http://sillydong.com/mypython/functions-of-digital-in-python.html#comments</comments>
		<pubDate>Sat, 29 Jan 2011 01:41:14 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[函数]]></category>
		<category><![CDATA[数字类型]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=369</guid>
		<description><![CDATA[标准类型内建函数：
cmp(obj1, obj2) 比较obj1和obj2，根据比较结果返回整型i:
i < 0 if obj1 < obj2
i > 0 if obj1 > obj2
i == 0 if obj1 == obj2 <a href="http://sillydong.com/mypython/functions-of-digital-in-python.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>标准类型内建函数：</p>
<p>cmp(obj1, obj2) 比较obj1和obj2，根据比较结果返回整型i:</p>
<p>i &lt; 0 if obj1 &lt; obj2</p>
<p>i &gt; 0 if obj1 &gt; obj2</p>
<p>i == 0 if obj1 == obj2<span id="more-369"></span></p>
<p>repr(obj)或`obj`    返回一个对象的字符串表示</p>
<p>str(obj)    返回对象适合可读性好的字符串表示</p>
<p>type(obj)   得到一个对象的类型，并返回相应的type对象</p>
<p>isinstance(obj, (type1, type2, type3))  测试对象是否列表中某类型，返回布尔值</p>
<p><br class="spacer_" /></p>
<p>数值工厂函数：</p>
<p>bool(obj)   返回obj对象的布尔值，也就是 obj.__nonzero__()方法的返回值</p>
<p>int(obj,base=10)    返回一个字符串或数值对象的整型表示，类似string,atoi()，可选进制参数</p>
<p>long(obj,base=10)   返回一个字符或数据对象的长整型表示，类似string.atol(),可选进制参数</p>
<p>float(obj)  返回一个字符串或数据对象的浮点型表示，类似string.atof()</p>
<p>complex(str) or complex(read.imag=0.0)  返回一个字符串的复数表示，或根据给定的实数及一个可选的虚数部分生成一个复数对象</p>
<p><br class="spacer_" /></p>
<p>数值运算内建函数：</p>
<p>abs(num)    返回num的绝对值</p>
<p>coerce(num1, num2)  将num1和num2转换为同一类型，然后以一个元组的形式返回</p>
<p>divmod(num1, num2)  除法取余运算的结合，返回一个元组(num1/num2, num1%num2)，对浮点型和复数的商进行下舍入（复数仅取实数部分的商）</p>
<p>pow(num1, num2, mod=1)  取num1的num2次方，如果提供mod参数，则计算结果再对mod进行取余运算</p>
<p>round(flt, ndig=1)  接受一个浮点型flt并对其四舍五入，保存ndig位小数，若不提供ndig参数，则默认小数点后0位，仅用于浮点型（整型也可用，但没意义）</p>
<p><br class="spacer_" /></p>
<p>仅用于整型的内建函数：</p>
<p>hex(num)    将数字转换成十六进制数并以字符串形式返回</p>
<p>oct(num)    将数字转换成八进制数并以字符串形式返回</p>
<p>chr(num)    将ASCII值的数字转换成ASCII字符，范围只能是0 &lt;= num &lt;= 255</p>
<p>ord(char)   接受一个ASCII或Unicode字符（长度为1的字符串），返回相应的ASCII值或Unicode值</p>
<p>unichr(num) 接受Unicode码值，返回其对应的Unicode字符，所接受的码值范围依赖于你的Python是构建于UCS-2还是UCS-4</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 02 日 -- <a href="http://sillydong.com/myweb/php-preg_match-summary.html" title="PHP用preg_match进行各种验证总结">PHP用preg_match进行各种验证总结</a></li><li>2011 年 01 月 21 日 -- <a href="http://sillydong.com/mypython/operators-of-digital-in-python.html" title="Python笔记——数字类型的操作符">Python笔记——数字类型的操作符</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myc/str2l-atoi.html" title="自己写的强力型字符转换长整型函数">自己写的强力型字符转换长整型函数</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mypython/functions-of-digital-in-python.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的运维经验总结</title>
		<link>http://sillydong.com/myserver/my-system-admin-experience.html</link>
		<comments>http://sillydong.com/myserver/my-system-admin-experience.html#comments</comments>
		<pubDate>Thu, 27 Jan 2011 16:36:23 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[管理]]></category>
		<category><![CDATA[网站]]></category>
		<category><![CDATA[运维]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=361</guid>
		<description><![CDATA[到现在做运维有三个月时间了，从不熟悉到熟悉，从什么都不清楚到清楚手里所有服务器状态，从什么都不会到独立运维十几台服务器，独立搭建监控平台，独立制定了完整的一套打包备份策略。部门的运维只有我一个人做，所以什么问题都由我处理，在累之外的好处就是我能接触的多，能学的多，这对个人能力的提升是有帮助的。日子也过得比较闷，随便做点总结吧，算是对三个月里技术之外自我提升的证明。 <a href="http://sillydong.com/myserver/my-system-admin-experience.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>到现在做运维有三个月时间了，从不熟悉到熟悉，从什么都不清楚到清楚手里所有服务器状态，从什么都不会到独立运维十几台服务器，独立搭建监控平台，独立制定了完整的一套打包备份策略。部门的运维只有我一个人做，所以什么问题都由我处理，在累之外的好处就是我能接触的多，能学的多，这对个人能力的提升是有帮助的。日子也过得比较闷，随便做点总结吧，算是对三个月里技术之外自我提升的证明。<span id="more-361"></span></p>
<p>1、工欲善其事，必先利其器。先对自己用的电脑配置一下，保证其能方便操作。</p>
<p>2、添加虚拟主机时Option使用“-index”，禁止列目录。</p>
<p>3、有新站需要上线时请衡量一下服务器承受能力后做安排。尤其注意不要在低内存的服务器上放过多站点，在低内存主机上也要留意mysql内存分配问题。</p>
<p>4、在多网卡主机上分配网站上线时尽量考虑网卡负载，平衡网卡流量。</p>
<p>5、网站程序目录权限设置为755。</p>
<p>6、FTP用户名使用“申请人姓名@网站域名”，便于管理。</p>
<p>7、转移数据库尽量使用导出为sql文件。如果数据库太大不方便导出导入操作，可以在关闭mysql服务之后复制数据库文件，但这种做法无法恢复数据库中innoDB类型的表。</p>
<p>8、在收藏夹中收藏所有phpmyadmin的地址，定期打开所有phpmyadmin，检查是否正常运行。</p>
<p>9、转移网站时留意目录属性，尤其是跨平台转移时。网站转移后先通过添加hosts来访问，没有问题后再改域名指向。</p>
<p>10、对服务器的任何操作请做备份，确认一切OK之后再做清理。对于删除操作不要擅做主张。</p>
<p>11、服务器不能通过ssh连接上时打开其power panel，若power panel不能控制，请联系主机提供商客服。</p>
<p>12、手机请7&#215;24小时开机，收到短信报警先打开网站确认是否确实出问题。连接上服务器后检查进程，检查资源使用，养成每天检查服务器的习惯。</p>
<p>13、Linux系统出现任何问题都是配置问题。如果必要请勿重启服务器。发现问题查日志，修改对应配置之后重启该项服务。</p>
<p>14、对服务器的任何操作请勿影响同事正常工作。</p>
<p>15、经常检查日志，检查脚本，看是否有不完善之处。</p>
<p>16、没事多练练正则表达式，多看看命令行，有好处。</p>
<p>17、以下命令要滚瓜烂熟：find grep sed awk top ps netstat ifconfig xargs egrep crontab，但不仅限于此。</p>
<p>18、熟悉mysql的命令，在phpmyadmin无法打开时只能用mysql的命令。</p>
<p>19、发现网站被挂黑链时，不要做任何修改，通知相关同事暂停修改站点。检查日志分析入侵途径，尽量寻找入侵者信息。可以有以下几个获取信息的途径：通过服务器记录下的IP，检查IP的地理位置，检查黑链中的域名，包括IP和地理位置，以及它们的whois相关信息，其中有些会有注册人，如果链接中注册人都是同一个，那可以基本肯定就是这个人，通过一些途径解决这个问题。</p>
<p>20、被挂马时，保存马之后分析马的特性。修改其源文件，添加短信报警内容，放在原位，如果对方再连接可以得到报警。当然别忘了找一下系统漏洞，把漏洞补好。</p>
<p>21、胆大心细，要有耐心。</p>
<p>22、不要将带有用户名密码的文档发送给任何人。</p>
<p>23、有问题多查文档，或者Google之。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html" title="WordPress MU切实可用的nginx rewrite规则">WordPress MU切实可用的nginx rewrite规则</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/my-system-admin-experience.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Python笔记——数字类型的操作符</title>
		<link>http://sillydong.com/mypython/operators-of-digital-in-python.html</link>
		<comments>http://sillydong.com/mypython/operators-of-digital-in-python.html#comments</comments>
		<pubDate>Fri, 21 Jan 2011 11:31:52 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[long]]></category>
		<category><![CDATA[operation]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[操作符]]></category>
		<category><![CDATA[数字]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=348</guid>
		<description><![CDATA[前一段时间开始接触Python编程，现在基本能开发了。参考的书是《Python核心编程（第二版）》，挺好的书。看书的时候做了一些笔记，最近比较忙，公司的服务器需要从各个方面进行整理，各种机制也不好，经常出岔子，报警机制什么的都需要重新策划，还有几台Win系统的等着换成Lin的系统。自从来了这个公司，做了这个部门唯一一个运维，掌握十几台主机之后，我的周末就没了…… <a href="http://sillydong.com/mypython/operators-of-digital-in-python.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>前一段时间开始接触Python编程，现在基本能开发了。参考的书是《Python核心编程（第二版）》，挺好的书，由于PDF文件过大，没法传上来，有需要的可以留言告知。看书的时候做了一些笔记，打算最近都贴出来，和大家分享。</p>
<p>最近比较忙，公司的服务器需要从各个方面进行整理，各种机制也不好，经常出岔子，报警机制什么的都需要重新策划，还有几台Win系统的等着换成Lin的系统。自从来了这个公司，做了这个部门唯一一个运维，掌握十几台主机之后，我的周末就没了……<span id="more-348"></span></p>
<p>标准类型值比较操作符：</p>
<p>expr1 < expr2   expr1小于expr2</p>
<p>expr1 > expr2   expr1大于expr2</p>
<p>expr1 <= expr2  expr1小于等于expr2</p>
<p>expr1 >= expr2  expr1大于等于expr2</p>
<p>expr1 == expr2  expr1等于expr2</p>
<p>expr1 != expr2  expr1不等于expr2(C风格)</p>
<p>expr1 <> expr2  expr1不等于expr2(ABC/Pascal风格)</p>
<p><br class="spacer_" /></p>
<p>标准类型对象身份比较操作符：</p>
<p>obj1 is obj2    obj1和obj2是同一个对象</p>
<p>obj1 is not obj2    obj1和obj2不是同一个对象</p>
<p><br class="spacer_" /></p>
<p>标准类型布尔操作符：</p>
<p>not expr    expr的逻辑非(否)</p>
<p>expr1 and expr2 expr1和expr2的逻辑与</p>
<p>expr1 or expr2  expr1和expr2的逻辑或</p>
<p><br class="spacer_" /></p>
<p>算数操作符：</p>
<p>+expr   结果符号不变</p>
<p>-expr   对结果符号取负</p>
<p>expr1 ** expr2  表达式1表达表达式2的结果</p>
<p>expr1 * expr2   表达式1乘以表达式2</p>
<p>expr1 / expr2   表达式1除以表达式2(传统除或真正除)</p>
<p>expr1 // expr2  表达式1地板除以表达式2</p>
<p>expr1 % expr2   表达式1对表达式2取余</p>
<p>expr1 + expr2   表达式1加表达式2</p>
<p>expr1 &#8211; expr2   表达式1减表达式2</p>
<p><br class="spacer_" /></p>
<p>位操作符（只适用于整型）</p>
<p>~num    单目运算，对数的每一位取反，结果为-(num+1)</p>
<p>num1 << num2    num1左移num2位</p>
<p>num1 >> num2    num1右移num2位</p>
<p>num1 &amp; num2 num1与num2按位与</p>
<p>num1 ^ num2 num1异或num2</p>
<p>num1 | num2 num1与num2按位或</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 01 月 29 日 -- <a href="http://sillydong.com/mypython/functions-of-digital-in-python.html" title="Python笔记——数字类型的几个函数">Python笔记——数字类型的几个函数</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myc/str2l-atoi.html" title="自己写的强力型字符转换长整型函数">自己写的强力型字符转换长整型函数</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mypython/operators-of-digital-in-python.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Crontab与shell不得不说的故事</title>
		<link>http://sillydong.com/myserver/crontab-shell-redirect.html</link>
		<comments>http://sillydong.com/myserver/crontab-shell-redirect.html#comments</comments>
		<pubDate>Wed, 29 Dec 2010 02:46:36 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[执行错误]]></category>
		<category><![CDATA[环境变量]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[重定向]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=331</guid>
		<description><![CDATA[最近做一个计划任务老出毛病，脚本手动执行一切正常，在crontab里面就不能正常执行，检查问题的时候始终不得方向，之后查看邮件才让我发现是crontab的环境变量设置问题。现在知道要怎么修改了，哈哈，拿出来与大家分享，这个小问题还是比较值得留意一下的。
Crontab执行时不会读取用户的环境变量，所以有时在crontab中添加了脚本任务后经常会发现执行失败，比如说执行ifconfig找不到这个命令之类的。大多数情况下是可能由于环境变量设置问题，如果有其他具体情况可以看root的mail里面邮件。因此，在编写脚本时要声明环境变量，防止发生此类错误。 <a href="http://sillydong.com/myserver/crontab-shell-redirect.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近做一个计划任务老出毛病，脚本手动执行一切正常，在crontab里面就不能正常执行，检查问题的时候始终不得方向，之后查看邮件才让我发现是crontab的环境变量设置问题。现在知道要怎么修改了，哈哈，拿出来与大家分享，这个小问题还是比较值得留意一下的。</p>
<p>Crontab执行时不会读取用户的环境变量，所以有时在crontab中添加了脚本任务后经常会发现执行失败，比如说执行ifconfig找不到这个命令之类的。大多数情况下是可能由于环境变量设置问题，如果有其他具体情况可以看root的mail里面邮件。因此，在编写脚本时要声明环境变量，防止发生此类错误。<span id="more-331"></span></p>
<p>在脚本开头第一行#!/bin/bash和脚本注释下添加两行内容，如下：</p>
<p>[bash]<br />
#!/bin/bash<br />
#这里放注释<br />
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<br />
export PATH<br />
#下面就是脚本的主要内容，可以声明变量可以写函数之类的<br />
[/bash]</p>
<p>注意要在所有其他非注释内容之前，这样做之后脚本在crontab中就能正常执行了。</p>
<p>网上还有说法说用source ~/.bash_profile，我尝试之后没成功，不知道是我添加的地方错了还是咋的。</p>
<p>另外在给crontab添加任务时不要忘了尽量让信息返回，才能更早发现问题更快解决问题。</p>
<p>crontab的前面5个字段的意思分别是：</p>
<p>分钟　（0-59）</p>
<p>小时　（0-23）</p>
<p>日期　（1-31）</p>
<p>月份　（1-12）</p>
<p>星期　（0-6）//0代表星期天</p>
<p>除了数字还有几个个特殊的符号就是”*”、”/”和”-”、”,”，*代表所有的取值范围内的数字，”/”代表每的意思,”*/5&#8243;表示每5个单位，”-”代表从某个数字到某个数字,”,”分开几个离散的数字，比如下面几个例子：</p>
<p>在12:00和13:00分别执行一次某命令，格式如下：</p>
<p>[bash]00 12,13 * * * command[/bash]</p>
<p>每两个小时执行一次命令</p>
<p>[bash]0 */2 * * * command[/bash]</p>
<p>晚上11点到早上8点之间每两个小时，早上八点</p>
<p>[bash]0 23-7/2，8 * * * command[/bash]</p>
<p>每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点</p>
<p>[bash]0 11 4 * 1-3 command[/bash]</p>
<p>1月1日早上4点</p>
<p>[bash]0 4 1 1 * command[/bash]</p>
<p>命令之后可以将命令的信息重定向。Linux中重定向规则如下（不仅仅可用于crontab）：</p>
<p>[bash]<br />
command &gt; filename 把标准输出重定向到一个新文件中<br />
command &gt;&gt; filename 把标准输出重定向到一个文件中(追加)<br />
command 1 &gt; fielname 把标准输出重定向到一个文件中<br />
command &gt; filename 2&gt;&amp;1 把标准输出和标准错误一起重定向到一个文件中<br />
command 2 &gt; filename 把标准错误重定向到一个文件中<br />
command 2 &gt;&gt; filename 把标准输出重定向到一个文件中(追加)<br />
command &gt;&gt; filename 2&gt;&amp;1 把标准输出和标准错误一起重定向到一个文件中(追加)<br />
command &lt; filename &gt;filename2 把command命令以filename文件作为标准输入，以filename2文件作为标准输出<br />
command &lt; filename 把command命令以filename文件作为标准输入<br />
command &lt;&lt; delimiter 把从标准输入中读入，直至遇到delimiter分界符<br />
command &lt;&amp;m 把文件描述符m作为标准输入<br />
command &gt;&amp;m 把标准输出重定向到文件描述符m中<br />
command &lt;&amp;- 把关闭标准输入<br />
command 2&gt;&amp;1 把command命令标准错误重定向到标准输出<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/crontab-shell-redirect.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>分享一些有用的Shell脚本片段</title>
		<link>http://sillydong.com/myshell/shell-fragments.html</link>
		<comments>http://sillydong.com/myshell/shell-fragments.html#comments</comments>
		<pubDate>Wed, 22 Dec 2010 15:26:32 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[正则]]></category>
		<category><![CDATA[脚本]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=323</guid>
		<description><![CDATA[写脚本多了就会发现，有的时候很多东西在很多脚本中都会要用到，这儿整理出其中几个，与大家分享。这中间有很多设计正则表达式，正则是好好东西，用途很广，推荐大家好好学学。即使最初看不懂也不要放弃，多写，写多了自然能很快反应需要什么样的正则来匹配什么样的字符串。 <a href="http://sillydong.com/myshell/shell-fragments.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>写脚本多了就会发现，有的时候很多东西在很多脚本中都会要用到，这儿整理出其中几个，与大家分享。这中间有很多设计正则表达式，正则是好好东西，用途很广，推荐大家好好学学。即使最初看不懂也不要放弃，多写，写多了自然能很快反应需要什么样的正则来匹配什么样的字符串。<span id="more-323"></span></p>
<p>检查当前执行脚本的用户是不是root用户，两种方法，如下：</p>
<p>[bash]<br />
#1 这个比较麻烦一点<br />
id | grep “uid=0(” >/dev/null<br />
if [ $? != "0" ]; then<br />
	uname -a | grep -i CYGWIN >/dev/null<br />
	if [ $? != "0" ]; then<br />
		echo “ERROR: The Webmin install script must be run as root”<br />
		echo “”<br />
		exit 1<br />
	fi<br />
fi<br />
#2 相对简单快捷一些<br />
if [ $(id -u) != "0" ]; then<br />
    echo “Error: You must be root to run this script, please use root to run this script”<br />
    exit 1<br />
fi<br />
[/bash]</p>
<p>获取系统的所有IP，不包含127.0.0.1，有三种办法</p>
<p>[bash]<br />
#1 要留意grep中的内容，不同系统要分别设置<br />
ifconfig | grep “venet0:0&#8243; &#8211;after-context=1 | sed -n &#8216;s/..*addr:\(..*\) P-t-P..*/\1/p&#8217; | sed &#8216;/127.0.0.1/d&#8217;<br />
#2 要留意addr后面的字符，有些是Bcast，不同系统要分别设置<br />
ifconfig | sed -n &#8216;s/..*addr:\(..*\) P-t-P..*/\1/p&#8217; | sed &#8216;/127.0.0.1/d&#8217;<br />
#3 基本不需要针对不同系统进行设置能够获取全部正确有用的IP<br />
ifconfig | sed &#8216;/Link/d&#8217; | sed &#8216;/127.0.0.1/d&#8217; | grep addr | awk &#8216;{print $2}&#8217; | sed &#8216;s/addr://g&#8217; | sed &#8216;/^$/d&#8217;<br />
[/bash]</p>
<p>在多网卡的机子上如果只需要获取一个，用下面的两个句子，第一个用于获取所有IP地址，第二个进行删选</p>
<p>[bash]<br />
IP=`ifconfig | sed &#8216;/Link/d&#8217; | sed &#8216;/127.0.0.1/d&#8217; | grep addr | awk &#8216;{print $2}&#8217; | sed &#8216;s/addr://g&#8217; | sed &#8216;/^$/d&#8217;`<br />
echo $IP | sed &#8216;s/ .*//&#8217;<br />
[/bash]</p>
<p>获取发行版信息，不是uname得到的那种结果，是确切的那个发行版，如下</p>
<p>[bash]<br />
cat /etc/issue | head -n 1 | awk &#8216;{print $1}&#8217;<br />
[/bash]</p>
<p>更多有用知识会在后续的日志中向各位呈现！</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2010 年 12 月 29 日 -- <a href="http://sillydong.com/myserver/crontab-shell-redirect.html" title="Crontab与shell不得不说的故事">Crontab与shell不得不说的故事</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/clean-black-chain.html" title="分享一个Linux上清除黑链的脚本">分享一个Linux上清除黑链的脚本</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/new-shell-for-rsync.html" title="用rsync进行两机备份的shell脚本（更新）">用rsync进行两机备份的shell脚本（更新）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/shell-fragments.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>分享一个Linux上清除黑链的脚本</title>
		<link>http://sillydong.com/myserver/clean-black-chain.html</link>
		<comments>http://sillydong.com/myserver/clean-black-chain.html#comments</comments>
		<pubDate>Wed, 22 Dec 2010 11:35:50 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sed.黑客]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[黑链]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=314</guid>
		<description><![CDATA[前段时间有个服务器被挂了黑链，这是我工作中安全方面的疏忽。不过挂黑链真的很讨厌啊！！！接触过黑链工具，没想到这次自己被挂了……悲剧！把服务器上涉及安全的都处理了一下，希望下次不会再这么悲剧！另外，挂黑链的人的姓名，住址，电话，QQ等信息都在我手里了，这次就算了，下次不会这么轻松了！ <a href="http://sillydong.com/myserver/clean-black-chain.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>前段时间有个服务器被挂了黑链，这是我工作中安全方面的疏忽。不过挂黑链真的很讨厌啊！！！接触过黑链工具，没想到这次自己被挂了……悲剧！把服务器上涉及安全的都处理了一下，希望下次不会再这么悲剧！另外，挂黑链的人的姓名，住址，电话，QQ等信息都在我手里了，这次就算了，下次不会这么轻松了！<span id="more-314"></span></p>
<p>在清理黑链的过程中写了一个脚本，可以快速准确清理掉被添加的黑链。代码如下：</p>
<p>[bash]<br />
#!/bin/bash<br />
# By Chen Zhidong<br />
# http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>#Begin<br />
FILES=`find ./ -type f -name “*.php” -or -name “*.htm” -or -name “*.html” |xargs fgrep -s -l “<script>#cool" |xargs ls -l | awk '{print $9}'`<br />
for file in $FILES<br />
do<br />
		cp $file ${file}.bad<br />
		sed -i 's/<br />
<style>#cool.*.display=\"none\"<\/script><\/div>//g' $file<br />
done<br />
exit 0<br />
#End<br />
[/bash]</p>
<p>使用之前请先研究一下所有黑链的特点，并且将sed中操作的正则表达式修改成针对你手中黑链的。</p>
<p>正则表达式请尽量严谨，以免伤及无辜！如果真不幸伤及了无辜，用备份的*.bad文件恢复一下。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 07 月 22 日 -- <a href="http://sillydong.com/myshell/dot-file-show-hide.html" title="苹果系统显示隐藏文件切换脚本">苹果系统显示隐藏文件切换脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/clean-black-chain.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Linux下调整Tomcat内存设置</title>
		<link>http://sillydong.com/myserver/linux-tomcat-memory.html</link>
		<comments>http://sillydong.com/myserver/linux-tomcat-memory.html#comments</comments>
		<pubDate>Wed, 22 Dec 2010 11:29:30 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=311</guid>
		<description><![CDATA[本文非常简短，仅仅是我刚刚用了的一小个经验，分享一下。
在tomcat安装目录下bin文件夹中，修改catalina.sh文件，在其中添加一行内容
JAVA_OPTS='-Xms111m -Xmx111m'
说明：Xms表示初始内存大小，Xmx表示最大占用内存大小。
把代码中111换成你需要设置的内存大小，重启tomcat就可以了，替换前衡量一下服务器的承受能力。 <a href="http://sillydong.com/myserver/linux-tomcat-memory.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>本文非常简短，仅仅是我刚刚用了的一小个经验，分享一下。</p>
<p>在tomcat安装目录下bin文件夹中，修改catalina.sh文件，在其中添加一行内容</p>
<p>JAVA_OPTS=&#8217;-Xms111m -Xmx111m&#8217;</p>
<p>说明：Xms表示初始内存大小，Xmx表示最大占用内存大小。</p>
<p>把代码中111换成你需要设置的内存大小，重启tomcat就可以了，替换前衡量一下服务器的承受能力。<span id="more-311"></span></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html" title="WordPress MU切实可用的nginx rewrite规则">WordPress MU切实可用的nginx rewrite规则</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/linux-tomcat-memory.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>转移DeDeCMS不得不留意的问题</title>
		<link>http://sillydong.com/myserver/care-while-moving-dedecms.html</link>
		<comments>http://sillydong.com/myserver/care-while-moving-dedecms.html#comments</comments>
		<pubDate>Wed, 22 Dec 2010 11:23:45 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[appserv]]></category>
		<category><![CDATA[dedecms]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[权限]]></category>
		<category><![CDATA[目录]]></category>
		<category><![CDATA[移站]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=305</guid>
		<description><![CDATA[公司的一个站是基于DeDeCMS搭建的，前段时间由于河蟹问题，需要转移。原来所在服务器的环境是用的appserv，现在转移目标是iis环境，两遍都是Windows的系统（Windows烦死了！！！），已经安装好php支持。
以上就是背景，下面是注意点： <a href="http://sillydong.com/myserver/care-while-moving-dedecms.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>公司的一个站是基于DeDeCMS搭建的，前段时间由于河蟹问题，需要转移。原来所在服务器的环境是用的appserv，现在转移目标是iis环境，两遍都是Windows的系统（Windows烦死了！！！），已经安装好php支持。</p>
<p>以上就是背景，下面是注意点：<span id="more-305"></span></p>
<p>1、站点数据库导入问题。DeDeCMS时间长了内容多了数据库比较大，在转移目标上不一定能通过phpmyadmin导入，会有大小限制，所以先用phpmyadmin建好账号和数据库之后，进操作系统后台，通过命令导入数据库，比较快，成功率也比较高。如下：</p>
<p>mysql &#8211;user=root &#8211;password=xxxxxx dbname < dbname.sql</p>
<p>2、站点目录权限问题。在DeDeCMS中权限问题是个大问题。不想wordpress，基本上除了上传什么的目录其他目录都是只要读和执行权限即可，但是在DeDeCMS上有些目录和文件需要写的权限，否则很多东西都会失败。</p>
<p>具体权限设置可以参考这个帖子<a href="http://bbs.dedecms.com/172474.html">http://bbs.dedecms.com/172474.html</a></p>
<p>另外，这儿还有一份权限设置的介绍也可以参考一下：</p>
<p>../  【站点上级目录】</p>
<p>//如果要使用后台的目录相关的功能需要有列出目录的权限 //0444</p>
<p>/  【站点根目录】</p>
<p>//需要执行和读取权限 如果要在根目录下面创建文件和目录的话需要有写入权限 //0755</p>
<p>/install 【安装程序目录】</p>
<p>//需要有执行和读取权限 //建议安装完成以后删除或者改名 //0555</p>
<p>/dede 【后台程序目录】</p>
<p>//需要有执行权限和读取权限 //建议安装完成以后修改目录名称 //0755</p>
<p>/include 【主程序目录】</p>
<p>//需要有写入、执行权限和读取权限 //0755 //建议在第一次安装后，去掉写入权限以及修改权限（需要重写配置文件时再暂时开启写入及修改权限）//0555</p>
<p>/member 【会员目录】</p>
<p>//需要执行读取和权限 //建议去掉写入权限以及修改权限//0555</p>
<p>/plus 【插件目录】</p>
<p>//需要有读取、写入和执行的权限 //建议在生成完站点地图和RSS文件后去掉写入权限以及修改权限 //0755</p>
<p>/data 【站点缓存数据等文件】</p>
<p>//需要有读取权限和写入修改权限 //建议去掉执行权限//0666</p>
<p>/html 【HTML文档默认目录】</p>
<p>//需要有读取修改和创建权限 //建议去掉执行权限 //0666</p>
<p>/templets【模板目录】</p>
<p>//需要有读取 修改写入 权限 //建议去掉执行权限 //0666</p>
<p>/uploads 【附件目录】</p>
<p>//需要写入读取权限 //建议去掉执行权限//0666</p>
<p>/company 【企业黄页程序目录】</p>
<p>//需要读取和执行权限 //建议去掉写入权限//0555</p>
<p>/special 【专题文件目录】</p>
<p>//需要执行、读取、写入和修改权限 //0755</p>
<p>/book 【书库模块程序目录】</p>
<p>//需要执行、读取、写入和修改权限 //0755</p>
<p>/ask 【问答模块程序目录】</p>
<p>//需要执行和读取权限 //建议去掉写入权限//0555</p>
<p>/group 【圈子模块程序目录】</p>
<p>//需要执行和读取权限 //建议去掉写入权限 //0555</p>
<h3  class="related_post_title">随机日志：</h3><ul class="related_post"><li>2012 年 03 月 02 日 -- <a href="http://sillydong.com/mymacos/mac-os-x-lion-xcode-homebrew.html" title="Mac OS X Lion与Xcode 4.3以及Homebrew的故事">Mac OS X Lion与Xcode 4.3以及Homebrew的故事</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 05 月 24 日 -- <a href="http://sillydong.com/myshell/shell-for-gedit.html" title="Gedit中编译C源代码并运行的外部工具脚本">Gedit中编译C源代码并运行的外部工具脚本</a></li><li>2011 年 01 月 21 日 -- <a href="http://sillydong.com/mypython/operators-of-digital-in-python.html" title="Python笔记——数字类型的操作符">Python笔记——数字类型的操作符</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/care-while-moving-dedecms.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>服务器服务监测脚本</title>
		<link>http://sillydong.com/myserver/service-monitor-shell.html</link>
		<comments>http://sillydong.com/myserver/service-monitor-shell.html#comments</comments>
		<pubDate>Tue, 23 Nov 2010 15:53:49 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php-cgi]]></category>
		<category><![CDATA[pureftpd-vsftpd]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[监测]]></category>
		<category><![CDATA[重启]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=300</guid>
		<description><![CDATA[由于最近一直在弄服务器，所以一直没有带来Arch Linux的东西，这篇文章给出的脚本依旧是为服务器准备的。写shell多了，C都快忘了怎么写了，这样不好啊……

公司的服务器经常莫名其妙就挂，ssh上去又是好的，看看进程发现服务根本没打开，为什么呢？服务器被重启了！我的前任留下一个check.sh脚本，用来监测apache等进程，脚本在监测到进程过多时就重启服务器，结果有些服务器没有设置好开机启动那些apache之类的，就悲剧了。我就重新写了一个脚本，代替了crontab中原来的check.sh，在进程过多时不是重启服务器而是重启服务，这下服务器正常多了，网站那边负责的朝我喊“XXXX网站挂了，什么问题？”少了，哈哈。 <a href="http://sillydong.com/myserver/service-monitor-shell.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>由于最近一直在弄服务器，所以一直没有带来Arch Linux的东西，这篇文章给出的脚本依旧是为服务器准备的。写shell多了，C都快忘了怎么写了，这样不好啊……</p>
<p>公司的服务器经常莫名其妙就挂，ssh上去又是好的，看看进程发现服务根本没打开，为什么呢？服务器被重启了！我的前任留下一个check.sh脚本，用来监测apache等进程，脚本在监测到进程过多时就重启服务器，结果有些服务器没有设置好开机启动那些apache之类的，就悲剧了。我就重新写了一个脚本，代替了crontab中原来的check.sh，在进程过多时不是重启服务器而是重启服务，这下服务器正常多了，网站那边负责的朝我喊“XXXX网站挂了，什么问题？”少了，哈哈。<span id="more-300"></span></p>
<p>废话多了点，脚本如下，使用前请一定看清代码并且修改其中一些路径之类的东西，以确保不会在你的服务器上造成什么不必要的伤害。</p>
<p>[bash]<br />
#!/bin/bash<br />
#	service &#8211;> name to test<br />
#	apache &#8211;> apache|apache2|http|httpd<br />
#	nginx &#8211;> nginx<br />
#	mysql &#8211;> mysql|mysqld<br />
#	php-cgi &#8211;> php-cgi<br />
#	vsftpd &#8211;> vsftp|vsftpd<br />
#	pure-ftpd &#8211;> pure-ftp|pure-ftpd<br />
#	apache-tomcat &#8211;> java<br />
# Set the service name you want to test and its max number of processes first.<br />
# Don&#8217;t forget to check the bin path for each service.<br />
# By Chen Zhidong<br />
# http://sillydong.com</p>
<p># This is a special one for the apache path is /usr/sbin</p>
<p>SERVICE=”apache2 mysqld vsftpd”<br />
SERVICE_MAX=(35 5 5)</p>
<p>LOGPATH=”/root”<br />
#APACHE_PATH=”/usr/sbin”<br />
#MYSQL_PATH=”/usr/local/mysql”<br />
#NGINX_PATH=”/usr/local/nginx”<br />
#PHP_PATH=”/usr/local/php”<br />
#TOMCAT_PATH=”/usr/local/apache-tomcat-6.0.26&#8243;<br />
#PURE_PATH=”/usr/local/pureftpd”<br />
i=0</p>
<p>if [ -e $LOGPATH/restart.log ]<br />
then<br />
	tail -n 10 $LOGPATH/restart.log > $LOGPATH/restart.tmp<br />
	rm -rf $LOGPATH/restart.log<br />
	mv $LOGPATH/restat.tmp $LOGPATH/restart.log<br />
fi</p>
<p>for serv in $SERVICE<br />
do<br />
	#echo “$serv”<br />
	#echo “$i”<br />
	#echo “${SERVICE_MAX[i]}”</p>
<p>	counter=0<br />
	counter=`ps -A | grep “$serv” | wc -l`<br />
	#echo “$counter”</p>
<p>	if [ $counter -eq 0 ];then<br />
        echo “$serv is off at $(date), starting&#8230;” >> $LOGPATH/restart.log<br />
        case $serv in<br />
            apache*|http*)<br />
                #echo “apache start”<br />
				$APACHE_PATH/bin/apachectl restart >> $LOGPATH/restart.log<br />
                ;;<br />
            nginx)<br />
                #echo “nginx start”<br />
                $NGINX_PATH/sbin/nginx -s reopen >> $LOGPATH/restart.log<br />
                ;;<br />
            mysql*)<br />
                #echo “mysql start”<br />
				if [ -e /etc/init.d/mysqld ];<br />
                then<br />
					/etc/init.d/mysqld restart >> $LOGPATH/restart.log<br />
				else<br />
					/etc/init.d/mysql restart >> $LOGPATH/restart.log<br />
				fi<br />
                ;;<br />
            php-cgi)<br />
                #echo “php-cgi start”<br />
                $PHP_PATH/sbin/php-fpm restart >> $LOGPATH/restart.log<br />
                ;;<br />
            vsftp*)<br />
                #echo “vsftpd start”<br />
                /etc/init.d/vsftpd restart >> $LOGPATH/restart.log<br />
                ;;<br />
            pure-ftp*)<br />
                #echo “pureftpd start”<br />
				$PURE_PATH/sbin/pure-ftpd -B >> $LOGPATH/restart.log<br />
                ;;<br />
            java*)   #apache-tomcat<br />
                #echo “tomcat start”<br />
				$TOMCAT_PATH/bin/startup.sh >> $LOGPATH/restart.log<br />
                ;;<br />
            *)<br />
                echo “Wrong service name while starting&#8230;” >> $LOGPATH/restart.log<br />
                ;;<br />
        esac<br />
	else<br />
		echo “$serv is on at $(date), next service&#8230;” >> $LOGPATH/restart.log<br />
    fi</p>
<p>    if [ $counter -gt ${SERVICE_MAX[i]} ];then<br />
        echo “$(date), too many $serv, needs to restart&#8230;” >> $LOGPATH/restart.log<br />
        case $serv in<br />
            apache*|http*)<br />
                #echo “apache restart”<br />
				$APACHE_PATH/bin/apachectl restart >> $LOGPATH/restart.log<br />
                ;;<br />
            nginx)<br />
                #echo “nginx restart”<br />
                $NGINX_PATH/sbin/nginx -s reload >> $LOGPATH/restart.log<br />
                ;;<br />
            mysql*)<br />
                #echo “mysql restart”<br />
				if [ -e /etc/init.d/mysqld ];<br />
                then<br />
					/etc/init.d/mysqld restart >> $LOGPATH/restart.log<br />
				else<br />
					/etc/init.d/mysql restart >> $LOGPATH/restart.log<br />
				fi<br />
                ;;<br />
            php-cgi)<br />
                #echo “php-cgi restart”<br />
                $PHP_PATH/sbin/php-fpm restart >> $LOGPATH/restart.log<br />
                ;;<br />
            vsftp*)<br />
                #echo “vsftpd restart”<br />
                /etc/init.d/vsftp* restart >> $LOGPATH/restart.log<br />
                ;;<br />
            pure-ftp*)<br />
                #echo “pureftpd restart”<br />
				$PURE_PATH/sbin/pure-ftpd -B >> $LOGPATH/restart.log<br />
                ;;<br />
            java*)   #apache-tomcat<br />
                #echo “tomcat restart”<br />
				$TOMCAT_PATH/bin/startup.sh >> $LOGPATH/restart.log<br />
                ;;<br />
            *)<br />
                echo “Warning: Wrong service name while restartiing&#8230;”  >> $LOGPATH/restart.log<br />
                ;;<br />
        esac<br />
    fi</p>
<p>    let “i++”<br />
done</p>
<p>exit 0</p>
<p>#End<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html" title="WordPress MU切实可用的nginx rewrite规则">WordPress MU切实可用的nginx rewrite规则</a></li><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/service-monitor-shell.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>用于管理Pure-FTPd用户的一个小脚本</title>
		<link>http://sillydong.com/myserver/pure-ftpd-user-manager.html</link>
		<comments>http://sillydong.com/myserver/pure-ftpd-user-manager.html#comments</comments>
		<pubDate>Sat, 20 Nov 2010 10:52:55 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[add user]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pure-ftpd]]></category>
		<category><![CDATA[user manage]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=291</guid>
		<description><![CDATA[一个用于添加和删除pure-ftpd用户的小脚本，只是为了减轻工作，并没什么技术含量。 <a href="http://sillydong.com/myserver/pure-ftpd-user-manager.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一个用于添加和删除pure-ftpd用户的小脚本，只是为了减轻工作，并没什么技术含量。<span id="more-291"></span></p>
<p>用法：</p>
<p>[bash]<br />
#添加用户：<br />
./pure-ftpd_ftpuser.sh create username userdirectory<br />
#删除用户：<br />
./pure-ftpd_ftpuser.sh drop username<br />
[/bash]</p>
<p>下面是脚本源代码：</p>
<p>[bash]<br />
#!/bin/bash<br />
# This script is used to add or delete users for pure-ftpd.<br />
# ./pure-ftpd_ftpuser.sh (create|drop)<br />
# By Chen Zhidong<br />
# http://sillydong.com</p>
<p>PURE=”/usr/local/pureftpd/”</p>
<p>if [ $# -lt 1 ]; then<br />
    echo “Syntax: ./pure-ftpd_ftpuser.sh (create|drop)”<br />
    exit<br />
fi</p>
<p>if [ $1 == "create" ]; then<br />
    if [ $# -lt 2 ]; then<br />
        echo “create username,userpath”<br />
        exit<br />
    fi<br />
	cd $PURE<br />
    echo “create user username:$2 directory:$3&#8243;<br />
	#pay attention to the user here, change it according to your system<br />
	$PURE/bin/pure-pw useradd $2 -u www -d $3<br />
	$PURE/bin/pure-pw mkdb pureftpd.pdb -f $PURE/etc/pureftpd.passwd<br />
	$PURE/bin/pure-pw show $2<br />
fi</p>
<p>if [ $1 == "drop" ]; then<br />
    if [ $# -lt 1 ]; then<br />
        echo “drop username”<br />
        exit<br />
    fi<br />
	$PURE/bin/pure-pw userdel $2<br />
	$PURE/bin/pure-pw mkdb pureftpd.pdb -f $PURE/etc/pureftpd.passwd<br />
	$PURE/bin/pure-pw list | awk &#8216;{print $1}&#8217;<br />
fi<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 15 日 -- <a href="http://sillydong.com/myserver/linux-find-shell.html" title="简单化Linux下find操作的脚本分享">简单化Linux下find操作的脚本分享</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/pure-ftpd-user-manager.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用rsync进行两机备份的shell脚本（更新）</title>
		<link>http://sillydong.com/myserver/new-shell-for-rsync.html</link>
		<comments>http://sillydong.com/myserver/new-shell-for-rsync.html#comments</comments>
		<pubDate>Sat, 20 Nov 2010 10:41:32 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=289</guid>
		<description><![CDATA[上回贴出了<a href="http://sillydong.com/myserver/shell-for-rsync.html" target="_blank">用rsync进行两机备份的shell脚本</a>一文，那个脚本当中有BUG，现在做一个更新，测试完全可用，贴出来，看了旧版脚本的朋友别忘了更新一下，脚本如下： <a href="http://sillydong.com/myserver/new-shell-for-rsync.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>上回贴出了<a href="http://sillydong.com/myserver/shell-for-rsync.html" target="_blank">用rsync进行两机备份的shell脚本</a>一文，那个脚本当中有BUG，现在做一个更新，测试完全可用，贴出来，看了旧版脚本的朋友别忘了更新一下，脚本如下：<span id="more-289"></span></p>
<p>[bash]<br />
#!/bin/bash<br />
# This script is used to do backup and rsync works for servers. Please finish the config part first before use it.<br />
# ./backup.sh (db_rsync|www_rsync)<br />
# By Chen Zhidong<br />
# http://sillydong.com</p>
<p>#########config begin####################</p>
<p>BINPATH=”/usr/bin”<br />
LOGPATH=”/home/backlogs”</p>
<p>DB_DUMP=”/home/database/”<br />
LOCAL_WWW=”/home/www/”</p>
<p>DB_USER=”xxx”<br />
DB_PASS=”xxxx”<br />
DB_HOST=”127.0.0.1&#8243;</p>
<p>PASSFILE=”/xxx/xxxxx”<br />
RSYNC_NAME=”xxxxxx”<br />
RSYNC_IP=”xxx.xxx.xxx.xxx”</p>
<p>#pay attention to the sed part of this sentence, check it before using!<br />
IP=`ifconfig | grep “venet0:0&#8243; &#8211;after-context=1 | sed -n &#8216;s/..*addr:\(..*\)  P-t-P..*/\1/p&#8217; | sed &#8216;/127.0.0.1/d&#8217;`</p>
<p>#########config end######################</p>
<p>db_dump(){<br />
	DBS=`$BINPATH/mysql &#8211;user=$DB_USER &#8211;host=$DB_HOST &#8211;password=$DB_PASS -Bse &#8216;show databases&#8217;`<br />
	for db in $DBS<br />
	do<br />
		case $db in<br />
			“information_schema”)<br />
			;;<br />
			“mysql”)<br />
			;;<br />
			“test”)<br />
			;;<br />
			*)<br />
				echo “Dump $db begin at $(date)” >> $LOGPATH/db_dump.log<br />
				$BINPATH/mysqldump &#8211;opt $db &#8211;user=$DB_USER &#8211;host=$DB_HOST &#8211;password=$DB_PASS  > $DB_DUMP/$db-$(date +%F).sql<br />
				echo “Dump $db done at $(date)” >> $LOGPATH/db_dump.log<br />
			;;<br />
		esac<br />
	done<br />
}</p>
<p>db_rsync(){<br />
	echo “Doing db_rsync&#8230;”<br />
	echo “db_rsync begin at $(date)!” >> $LOGPATH/db_rsync.log<br />
	rsync -rvlHpogDtS &#8211;delete &#8211;password-file=$PASSFILE $DB_DUMP &#8211;exclude *\log\* &#8211;exclude *\backup\* &#8211;exclude *.rar &#8211;exclude *.zip &#8211;exclude *mysql* &#8211;exclude *.err* &#8211;exclude *.pid* &#8211;exclude *\test\* rsync://$RSYNC_NAME@$RSYNC_IP/${IP}_db_lio >> $LOGPATH/db_rsync.log<br />
	echo “db_rsync done at $(date)!” >> $LOGPATH/db_rsync.log<br />
}</p>
<p>www_rsync(){<br />
	echo “Doing www_rsync&#8230;”<br />
	echo “www_rsync begin at $(date)!” >> $LOGPATH/www_rsync.log<br />
	rsync -rvlHpogDtS &#8211;delete &#8211;password-file=$PASSFILE $LOCAL_WWW &#8211;exclude *\log\* &#8211;exclude *\backup\* &#8211;exclude *.rar &#8211;exclude *.zip rsync://$RSYNC_NAME@$RSYNC_IP/${IP}_www_lio >> $LOGPATH/www_rsync.log<br />
	echo “www_rsync done at $(date)!” >> $LOGPATH/www_rsync.log<br />
}</p>
<p>#Script begin here</p>
<p>if [ ! -d $LOGPATH ];then<br />
	mkdir $LOGPATH<br />
fi</p>
<p>case $1 in<br />
	db_rsync)<br />
		db_dump 2>> $LOGPATH/rsync_error.log<br />
		db_rsync 2>> $LOGPATH/rsync_error.log<br />
	;;<br />
	www_rsync)<br />
		www_rsync 2>> $LOGPATH/rsync_error.log<br />
	;;<br />
	*)<br />
		echo “$(date) You didn&#8217;t add parameter in your crontab.” >> $LOGPATH/crontab.log<br />
		echo “Syntax: backup.sh (db_rsync|www_rsync)” >> $LOGPATH/crontab.log<br />
	;;<br />
esac</p>
<p>exit 0<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html" title="用shell来为rsyncd增加删除站点配置">用shell来为rsyncd增加删除站点配置</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/new-shell-for-rsync.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress MU切实可用的nginx rewrite规则</title>
		<link>http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html</link>
		<comments>http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html#comments</comments>
		<pubDate>Sat, 20 Nov 2010 10:35:10 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpmu]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=283</guid>
		<description><![CDATA[话说公司有个WordPress MU的多博客系统，这个博客系统是好东西的样子，但是最初负责的人没有多研究一下，也没有装什么优化的插件，就直接开用，到现在数据库达到了将近3个G，没办法啊，只好给它换个，以免影响到其他网站。这个WPMU本来是在Apache下的，挪到新的上面之后用的是nginx，打开后台管理不行了，猜是rewrite的关系，Google之后找到了相关的东西，但是写得不明不白，里面的rewrite规则有误，结果弄好之后除了域名之外的地址都跳转到同服务器上的另外一个站，尝试多次之后才成功，现在贴出个完整的在nginx中安装WPMU的配置，方便大家。 <a href="http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>傻东我找到实习工作啦！哈哈～实习工作是做系统运维，前段时间刚接手工作，对公司的环境也不熟悉，经常手忙脚乱的，还是学得不扎实啊。到现在工作两个礼拜了，对各个服务器上配置环境熟悉了很多，处理问题速度快了不少，碰到一些小问题也能够很快解决了。</p>
<p>话说公司有个WordPress MU的多博客系统，这个博客系统是好东西的样子，但是最初负责的人没有多研究一下，也没有装什么优化的插件，就直接开用，到现在数据库达到了将近3个G，没办法啊，只好给它换个，以免影响到其他网站。这个WPMU本来是在Apache下的，挪到新的上面之后用的是nginx，打开后台管理不行了，猜是rewrite的关系，Google之后找到了相关的东西，但是写得不明不白，里面的rewrite规则有误，结果弄好之后除了域名之外的地址都跳转到同服务器上的另外一个站，尝试多次之后才成功，现在贴出个完整的在nginx中安装WPMU的配置，方便大家。<span id="more-283"></span></p>
<p>[bash]<br />
server<br />
{<br />
	listen       xxx.xxx.xxx.xxx:port;<br />
	server_name  www.hostname.com hostname.com;<br />
	index index.html index.htm index.php;<br />
	root  /your/document/root/for/this/hostname;</p>
<p>    location /<br />
	{<br />
		rewrite ^(.*/)?files/(.*) /wp-content/blogs.php?file=$2 last;<br />
		if (!-e $request_filename) {<br />
			rewrite ^.+?(/wp-.*) $1 last;<br />
			rewrite ^.+?(/.*\.php)$ $1 last;<br />
			rewrite ^ /index.php last;<br />
		}<br />
	}</p>
<p>    location ~ .*\.(php|php5)?$<br />
    {<br />
		include enable_php5.conf;<br />
    }</p>
<p>    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$<br />
    {<br />
		expires      30d;<br />
    }</p>
<p>    location ~ .*\.(js|css)?$<br />
    {<br />
		expires      1h;<br />
    }</p>
<p>	log_format hostname_log &#8216;$remote_addr &#8211; $remote_user [$time_local] “$request” &#8216;<br />
	&#8216;$status $body_bytes_sent “$http_referer” &#8216;<br />
	&#8216;”$http_user_agent” $http_x_forwarded_for&#8217;;<br />
}</p>
<p>[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/linux-tomcat-memory.html" title="Linux下调整Tomcat内存设置">Linux下调整Tomcat内存设置</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/nginx-rewrite-for-wp-mu.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>用rsync进行两机备份的shell脚本</title>
		<link>http://sillydong.com/myserver/shell-for-rsync.html</link>
		<comments>http://sillydong.com/myserver/shell-for-rsync.html#comments</comments>
		<pubDate>Fri, 12 Nov 2010 05:03:14 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[备份]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[灾备]]></category>
		<category><![CDATA[运维]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=277</guid>
		<description><![CDATA[最近做服务器运维，用rsync进行两机备份的话比较好，对数据保全比较好。因此写了这个脚本，加进crontab当中，定期对服务器备份数据库以及www目录下的网站。
脚本如下，错误之处还请指出，谢谢！ <a href="http://sillydong.com/myserver/shell-for-rsync.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近做服务器运维，用rsync进行两机备份的话比较好，对数据保全比较好。因此写了这个脚本，加进crontab当中，定期对服务器备份数据库以及www目录下的网站。</p>
<p>脚本如下，使用前请先针对自己的服务器环境设置变量值，错误之处还请指出，谢谢！原创脚本，转载请保留原作者信息！<span id="more-277"></span></p>
<p>[bash]<br />
#/bin/bash<br />
# This script is used to do backup and rsync works for servers.<br />
# ./backup.sh (db_rsync|www_rsync)<br />
# By Chen Zhidong<br />
# http://sillydong.com</p>
<p># 获取可执行文件路径<br />
MYSQL=”$(which mysql)”<br />
MYSQLDUMP=”$(which mysqldump)”<br />
GZIP=”$(which gzip)”</p>
<p>#定义数据库dump目录<br />
DB_DUMP=”/home/www/database/”</p>
<p>#定义MySQL认证<br />
DB_USER=”"<br />
DB_PASS=”"<br />
DB_HOST=”127.0.0.1&#8243;</p>
<p>#定义www目录<br />
LOCAL_WWW=”"<br />
RSYNC_WWW=”"</p>
<p>#定义本地rsync密码文件位置<br />
PASSFILE=”"<br />
RSYNC_NAME=”"<br />
RSYNC_IP=”"</p>
<p>#获取本地AccessIP用作后面rsync的文件夹<br />
IP=`ifconfig | grep “venet0:0&#8243; &#8211;after-context=1 | sed -n &#8216;s/..*addr:\(..*\) P-t-P..*/\1/p&#8217; | sed &#8216;/127.0.0.1/d&#8217;`</p>
<p>function db_dump{<br />
	DBS=”$($MYSQL -u&#8217;$DB_USER&#8217; -h $DB_HOST -p&#8217;$DB_PASS&#8217; -Bse &#8216;show databases&#8217;)”<br />
	for db in $DBS<br />
	do<br />
		case $db in<br />
 		“information_schema”)<br />
			;;<br />
  		“mysql”)<br />
			;;<br />
		“test”)<br />
			;;<br />
		*)<br />
 			echo “Dump $db begin at $(date)” >> $DB_DUMP/db_dump.log<br />
 			$MYSQLDUMP &#8211;opt $db -u&#8217;$DB_USER&#8217; -h $DB_HOST -p&#8217;$DB_PASS&#8217;  > $DB_DUMP/$(date +%F)-$db.sql<br />
		esac<br />
	done<br />
	echo “Dump $db done at $(date)” >> $DB_DUMP/db_dump.log<br />
}</p>
<p>function db_rsync{<br />
	echo “db_rsync begin at $(date)!” >> db_rsync.log<br />
	rsync -rvlHpogDtS &#8211;delete &#8211;password-file=$PASSFILE /home/database &#8211;exclude *\log\* &#8211;exclude *\backup\* &#8211;exclude *.rar &#8211;exclude *.zip rsync://$RSYNC_NAME@$RSYNC_IP/$IP_db_lio >> $DB_DUMP/db_rsync.log<br />
	echo “db_rsync done at $(date)!” >> db_rsync.log<br />
}</p>
<p>function www_rsync{<br />
	echo “www_rsync begin at $(date)!” >> www_rsync.log<br />
	rsync -rvlHpogDtS &#8211;delete &#8211;password-file=$PASSFILE /home/www &#8211;exclude *\log\* &#8211;exclude *\backup\* &#8211;exclude *.rar &#8211;exclude *.zip rsync://$RSYNC_NAME@$RSYNC_IP/$IP_www_lio >> $DB_DUMP/db_rsync.log<br />
	echo “www_rsync done at $(date)!” >> www_rsync.log<br />
}</p>
<p>case $1 in<br />
db_rsync)<br />
	db_dump 2>> /home/rsync_error.log<br />
	db_rsync 2>> /home/rsync_error.log<br />
;;<br />
www_rsync)<br />
	www_rsync 2>> /home/rsync_error.log<br />
;;<br />
*)<br />
    echo “$(date)You didn&#8217;t add parameter in your crontab.” >> crontab.log<br />
	echo “Syntax: backup.sh (db_rsync|www_rsync)” >> crontab.log<br />
;;<br />
esac<br />
[/bash]</p>
<p>另有一脚本，用于在备份机上rsyncd.conf中添加记录，如下：</p>
<p>[bash]<br />
#/bin/bash<br />
# ./rsyncd.sh IP</p>
<p># for db<br />
echo “”<br />
echo “[$1_db_lio]” >> /etc/rsyncd.conf<br />
echo “path = /backup/mysql/$1&#8243; >> /etc/rsyncd.conf<br />
echo “uid = root” >> /etc/rsyncd.conf<br />
echo “gid = root” >> /etc/rsyncd.conf<br />
echo “read only = false” >> /etc/rsyncd.conf<br />
echo “ignore errors” >> /etc/rsyncd.conf<br />
echo “secrets file = /etc/rsyncd.pas” >> /etc/rsyncd.conf<br />
echo “host allow $1&#8243; >> /etc/rsyncd.conf</p>
<p>#for www<br />
echo “”<br />
echo “[$1_www_lio]” >> /etc/rsyncd.conf<br />
echo “path = /backup/vhosts/rsyncfiles/$1&#8243; >> /etc/rsyncd.conf<br />
echo “uid = root” >> /etc/rsyncd.conf<br />
echo “gid = root” >> /etc/rsyncd.conf<br />
echo “read only = false” >> /etc/rsyncd.conf<br />
echo “ignore errors” >> /etc/rsyncd.conf<br />
echo “secrets file = /etc/rsyncd.pas” >> /etc/rsyncd.conf<br />
echo “host allow $1&#8243; >> /etc/rsyncd.conf</p>
<p>tail -n 17 /etc/rsyncd.conf<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html" title="用shell来为rsyncd增加删除站点配置">用shell来为rsyncd增加删除站点配置</a></li><li>2011 年 01 月 27 日 -- <a href="http://sillydong.com/myserver/my-system-admin-experience.html" title="我的运维经验总结">我的运维经验总结</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2010 年 11 月 20 日 -- <a href="http://sillydong.com/myserver/new-shell-for-rsync.html" title="用rsync进行两机备份的shell脚本（更新）">用rsync进行两机备份的shell脚本（更新）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/shell-for-rsync.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML加JavaScript随机密码生成器源码</title>
		<link>http://sillydong.com/myweb/random-password-generator.html</link>
		<comments>http://sillydong.com/myweb/random-password-generator.html#comments</comments>
		<pubDate>Sat, 06 Nov 2010 03:34:06 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[WEB]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascrip]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[随机密码]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=260</guid>
		<description><![CDATA[最近对随机密码有需求，找到一个在线的获取网页，挺好的，但是网页上好多广告，太花哨了，有点讨厌，所以自己动手，网上搜搜加我的半吊子html跟javascript知识写了一个，特此贴出源代码，各位看官随便看看。
原理很简单，选择字符集，分大写字母、小写字母、数字和特殊字符组成一个字符数组，从字符数组中随机取字符组成随机密码。 <a href="http://sillydong.com/myweb/random-password-generator.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近对随机密码有需求，找到一个在线的获取网页，挺好的，但是网页上好多广告，太花哨了，有点讨厌，所以自己动手，网上搜搜加我的半吊子html跟javascript知识写了一个，特此贴出源代码，各位看官随便看看。</p>
<p>原理很简单，选择字符集，分大写字母、小写字母、数字和特殊字符组成一个字符数组，从字符数组中随机取字符组成随机密码。<span id="more-260"></span></p>
<p>[html]<br />
<html><br />
	<head><br />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></p>
<style type="text/css">
			body,td{
				font-size: 12px;
				color: #000000;
			}
			a {
				color: #000066;
				text-decoration: none;
			}
			a:hover {
				color: #FF6600;
				text-decoration: underline;
			}
			.STYLE1 {
				font-size: 18px;
				font-weight: bold;
			}
		</style>
<p>		<script type='text/javascript'>
			function getpw(length, upper, lower, numbers, special) {
				var chars = '';
				if(upper) chars += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
				if(lower) chars += 'abcdefghijklmnopqrstuvwxyz';
				if(numbers) chars += '0123456789';
				if(special) chars += '!#$%&#038;*+-=?@^_~';</p>
<p>				var pw = '';
				chars = chars.split('');
				for(var i = 0; i < length; i++)
					pw += chars[Math.floor(Math.random() * chars.length)];</p>
<p>				return pw;
			}
			function generate() {
				var length = document.getElementById('length').value;
				var upper = lower = numbers = special = false;
				if(document.getElementById('upper').checked) upper = true;
				if(document.getElementById('lower').checked) lower = true;
				if(document.getElementById('numbers').checked) numbers = true;
				if(document.getElementById('special').checked) special = true;</p>
<p>				var Password = '';
				if(length<=0||length>50)
					alert('随机密码长度设置错误，请重设！');
				else if (!upper &#038;&#038; !lower &#038;&#038; !numbers &#038;&#038; !special)
					alert('请选择字符集！');
				else
					Password += getpw(length, upper, lower, numbers, special) + '\r\n';</p>
<p>				document.getElementById('password').value = Password.substring(0, Password.length-2);
			}
		</script><br />
	</head><br />
	<body></p>
<table width="39%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td colspan="2">
<div align="center" class="STYLE1">随机密码生成器</div>
</td>
</tr>
<tr>
<td width="23%">随机密码长度：</td>
<td width="77%">
<input type="text" id='length' size="4" value="16">   默认为16位，最小为1位，最大为50位</td>
</tr>
<tr>
<td width="23%">选择字符集：</td>
<td>
<input type='checkbox' id='upper' value='1' checked='checked'>大写字母</p>
<input type='checkbox' id='lower' value='1' checked='checked'>小写字母</p>
<input type='checkbox' id='numbers' value='1' checked='checked'>数字</p>
<input type='checkbox' id='special' value='1' checked='checked'>特殊字符
				</td>
</tr>
<tr>
<td></td>
<td colspan='2' class='submit'>
<input type='submit' id='generate' value='点击获取随机密码' onclick='generate();'></td>
</tr>
</table>
<input type='text' id='password' size='60'>
	</body><br />
</html><br />
[/html]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/shell-html-to-xml-handler.html" title="将html处理成xml的shell">将html处理成xml的shell</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myweb/random-password-generator.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>我的刷机经验</title>
		<link>http://sillydong.com/mylife/my-upgrade-experience.html</link>
		<comments>http://sillydong.com/mylife/my-upgrade-experience.html#comments</comments>
		<pubDate>Wed, 20 Oct 2010 10:38:48 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[E71]]></category>
		<category><![CDATA[JAF]]></category>
		<category><![CDATA[凤凰]]></category>
		<category><![CDATA[刷机]]></category>
		<category><![CDATA[固件]]></category>
		<category><![CDATA[备份]]></category>
		<category><![CDATA[强刷]]></category>
		<category><![CDATA[网络锁]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=254</guid>
		<description><![CDATA[本人手机是E71，具体的刷机过程就不多说了，各种手机论坛上有各种手机的刷机教程，可以参考。本文只说一些我在刷机过程中注意到的几点东西，仅希望各位不要犯我相同的错误。
刷机最重要的一点：刷机有风险，刷前请备份！ <a href="http://sillydong.com/mylife/my-upgrade-experience.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>本人手机是E71，具体的刷机过程就不多说了，各种手机论坛上有各种手机的刷机教程，可以参考。本文只说一些我在刷机过程中注意到的几点东西，仅希望各位不要犯我相同的错误。</p>
<p>刷机最重要的一点：刷机有风险，刷前请备份！<span id="more-254"></span></p>
<p>备份是很重要的一步。我的E71在差点成为板砖时被我好不容易通过备份的数据抢救回来。具体要备份的东西分为两类，第一类是用户数据，包括重要的短信、所有的名片、一些待办事项等，你看着那些有用就备份下来，备份方式可以选择备份到存储卡上或者放在电脑里。插一句，刷机时候最好把存储卡拔出来。第二类就是硬件的数据了。</p>
<p>备份硬件数据，首先拿纸币记下一下信息，一般在电池下方，例如IMEI、CODE、IC、WLAN、TYPE、MODEL等等一系列信息，这步不是必要的，只是做个记录。如果刷机需要改CODE用某个固件的话，最好还是记住原来的CODE，没坏处。改CODE方法就不多说了，用NSS或者JAF都可以改，google一下，你能知道得很清楚。</p>
<p>其次，备份PM。很多手机在刷机时不小心降级了怎的会突然出现网络锁，开机显示SIM卡无效之类的东西，问题就出在PM上，所以它的备份是必要的，备份了只需要将备份文件写入，如果没有备份的话很可能就要花上一些大洋去专门修理了，而且据说现在RPL（不晓得什么东西的自己google）不能买了，那个卖这东西的网站挂了，也就是说只能换板了，相关具体的东西可以看这里 <a href="http://bbs.dospy.com/viewthread.php?tid=6366034&amp;bbsid=173">http://bbs.dospy.com/viewthread.php?tid=6366034&amp;bbsid=173</a> 。当然，这在各个机型间也是有差别的，具体的可以看这儿 <a href="http://bbs.dospy.com/thread-7482092-1-173-7.html">http://bbs.dospy.com/thread-7482092-1-173-7.html</a> 。</p>
<p>备份的过程如下，用JAF，在Service Setting里面用Read PM来备份，先备份一个从0到512的，再单独备份308区域，找个好地方放好这两个文件。具体看这里 <a href="http://www.dospy.com/bbs/viewthread.php?tid=4450773&amp;bbsid=173">http://www.dospy.com/bbs/viewthread.php?tid=4450773&amp;bbsid=173</a> 。</p>
<p>我在刷机时候还真不小心降级出现网络锁，在尝试了很多次重刷高版本连续失败之后只要将PM写回，也就是把Read PM改成Write PM。但是尝试了很多次之后发现这样做还是没用，写不进去，最后阴差阳错终于让我找出了要如何写。拔掉SIM卡，正常开机，此时不会显示网络锁，现在再刷PM，这样才可以，刷好之后再刷ROM进去。我总结似乎是在锁定的情况下不能写的样子，所以才会每次都失败。希望各位看官如果遇到了这个问题不要再走弯路了。</p>
<p>关于ROM的选择，你可以用Navifirm根据机型下载官方的版本，也可以上一些手机论坛去找找一些个人DIY作品。这些作品中很多还是不错的，可以尝试尝试。不过请上信得过的论坛下信得过的固件，下前看看评论，看看大家说什么，不要碰到植入了病毒什么的固件，到时候损失的就是你了。</p>
<p>刷机不恐怖，只要胆大心细就行。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li><li>2011 年 04 月 15 日 -- <a href="http://sillydong.com/myshell/rsyncd-configure-shell.html" title="用shell来为rsyncd增加删除站点配置">用shell来为rsyncd增加删除站点配置</a></li><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylife/my-upgrade-experience.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux各文件系统比较</title>
		<link>http://sillydong.com/myserver/linux-filesystem.html</link>
		<comments>http://sillydong.com/myserver/linux-filesystem.html#comments</comments>
		<pubDate>Wed, 06 Oct 2010 14:06:04 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[ext]]></category>
		<category><![CDATA[ext2]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[ext4]]></category>
		<category><![CDATA[fdisk]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[jfs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[makefs]]></category>
		<category><![CDATA[reiserfs]]></category>
		<category><![CDATA[xfs]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=247</guid>
		<description><![CDATA[目前网络中充斥着各种Linux文件系统，用户很难在不了解这么多种文件系统的情况下从中做出一个好的并且适合自己选择，下面的内容转自LinuxEden网站，由于年代久远，原文链接已丢失，并且我在其中加入了EXT4的介绍。熟悉文件系统特性并选择一个合适的文件系统有利于充分利用磁盘物理属性。 <a href="http://sillydong.com/myserver/linux-filesystem.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>目前网络中充斥着各种Linux文件系统，用户很难在不了解这么多种文件系统的情况下从中做出一个好的并且适合自己选择，下面的内容转自<a href= "http://www.linuxeden.com">LinuxEden</a>网站，由于年代久远，原文链接已丢失，并且我在其中加入了EXT4的介绍。熟悉文件系统特性并选择一个合适的文件系统有利于充分利用磁盘物理属性。<span id="more-247"></span></p>
<p>1、ext</p>
<p>ext 是第一个专门为 Linux 的文件系统类型,叫做扩展文件系统。它在 1992 年 4 月完成的。它为 Linux 的发展取得了重要作用。但是在性能和兼容性上存在许多缺陷。现在已经很少使用了。</p>
<p>2、ext2</p>
<p>ext2 是为解决 ext 文件系统的缺陷而设计的可扩展的高性能的文件系统。又被称为二级扩展文件系统。它是在 1993 年发布的,设计者是 Rey Card。ext2 是 Linux 文件系统类型中使用最多的格式。并且在速度和 CPU 利用率上较突出,是 GNU/Linux 系统中标准的文件系统,其特点为存取文件的性能极好,对于中小型的文件更显示出优势,这主要得利于其簇快取层的优良设计。2000 年以前几乎所有的 Linux 发行版都用 ext2 作为默认的文件系统。</p>
<p>3、ext3</p>
<p>ext3 是由开放资源社区开发的日志文件系统,主要开发人员是 Stephen tweedie。ext3被设计成是 ext2 的升级版本,尽可能地方便用户从 ext2fs 向 ext3fs 迁移。ext3 在 ext2的基础上加入了记录元数据的日志功能,努力保持向前和向后的兼容性。这个文件系统被称为 ext2 的下一个版本。也就是在保有目前 ext2 的格式之下再加上日志功能。ext3 是一种日志式文件系统。日志式文件系统的优越性在于:由于文件系统都有快取层参与运作,如不使用时必须将文件系统卸下,以便将快取层的资料写回磁盘中。因此每当系统要关机时,必须将其所有的文件系统全部卸下后才能进行关机。如果在文件系统尚未卸下前就关机 (如停电) 时,下次重开机后会造成文件系统的资料不一致,故这时必须做文件系统的重整工作,将不一致与错误的地方修复。</p>
<p>4、ext4</p>
<p>ext4 是一种针对 ext3 系统的扩展日志式文件系统,是 专 门为 Linux 开发的原始的扩展文件系统(ext 或 extfs)的第四版。它 具有更高的兼容性并且消 除了存储限制,从 ext3升级至 ext4 不需要格式化分区。它的子目录具有可伸缩性。ext4 使用了一个多块分配来在一次调用中分配很多块。替换掉每次分配一个块,减少系统开销。在延时分配和 extends 上十分有用。而延迟分配是一个性能特性(它不修改磁盘格式)。相对于传统文件系统(例如ext3、reiser3、etc)所做的立刻分配块提供了更好的性能。</p>
<p>5、JFS</p>
<p>jsf 提供了基于日志的字节级文件系统,该文件系统是为面向事务的高性能系统而开发的。jsf 的开发者包括 AIX 的 jsf 的主要开发者。在 AIX 上,jfs 已经经受住了考验。它是可靠、快速和容易使用的。2000 年 2 月,ibm 宣布在一个开放资源许可证下,移植 linux 版的 JSF 文件系统。 JSFs 也是一个有大量用户安装使用的企业级文件系统。它具有可伸缩性和健壮性,与非日志文件系统相比,它的优点是其快速重启能力:Jfs 能够在几秒或几分钟内就把文件系统恢复到一致状态。虽然 jsf 主要是为满足服务器的高吞吐量和可靠性需求而设计的,jsf 还可用于想得到高性能和可靠性的客户机配置因为在系统崩溃时,jsf 能提供快速文件系统重启时间,所以它是因特网文件服务器的关键技术。使用数据库日志处理技术,jsf 能在几秒或几分钟之内把文件系统恢复到一致状态。而在非日志文件系统中,文件恢复可能花费几小时或几天。</p>
<p>6、ReiserFS</p>
<p>ReiserFS 的第一次公开亮相是在 1997 年 7 月 23 日,Hans Reiser 把他的基于平衡树结构的 ReiserFS 文件系统在网上公布。ReiserFS 3.6.x 是由 Hans Reiser 和他的在 Namesys的开发组共同开发设计的。Reiserfs 被看作是一个更加激进和现代的文件系统。传统的UNIX 文件系统是按盘块来进行空间分配的,对于目录和文件等的查找使用了简单的线性查找。这些设计在当时是合适的,但随着磁盘容量的增大和应用需求的增加,传统文件系统在存储效率,速度和功能上已显落后。 ReiserFS 一个最受人批评的缺点是每升级一个版本,都将要将磁盘重新格式化一次。</p>
<p>7、xfs</p>
<p>xfs 是一种非常优秀的日志文件系统,它是 SGI 公司设计的。xfs 被称为业界最先进的、最具可升级性的文件系统技术。SGI 的 xfs 可为 linux 和开放资源社区带来的新特性有:可升级性:xfs 被设计成可升级,以面对大多数的存储容量和 i/o 存储需求,可处理大型文件和包含巨大数量文件的大型目录,满足二十一世纪快速增长的磁盘需求。xfs 有能力动态地为文件分配索引空间,使系统形成高效支持大数量文件的能力。优秀的 i/o 性能:典型的现代服务器使用大型的条带式磁盘阵列,以提供达数 gb/秒的总带宽。xfs 可以很好地满足 I/O 请求的大小和并发 I/O 请求的数量。xfs 可作为 root 文件系统,并被 lilo 支持.在 NFS 服务器上使用也没问题.支持软件磁盘阵列(RAID)和虚拟集群(LVM)。由于 xfs 比较复杂,实施起来有一些难度,所以目前 xfs 主要应用于 Linux 企业应用的高端。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 10 月 06 日 -- <a href="http://sillydong.com/myserver/proposal-for-full-use-of-disk-properties.html" title="Linux充分利用磁盘物理属性的建议">Linux充分利用磁盘物理属性的建议</a></li><li>2012 年 03 月 15 日 -- <a href="http://sillydong.com/myserver/linux-find-shell.html" title="简单化Linux下find操作的脚本分享">简单化Linux下find操作的脚本分享</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/linux-filesystem.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux充分利用磁盘物理属性的建议</title>
		<link>http://sillydong.com/myserver/proposal-for-full-use-of-disk-properties.html</link>
		<comments>http://sillydong.com/myserver/proposal-for-full-use-of-disk-properties.html#comments</comments>
		<pubDate>Wed, 06 Oct 2010 13:30:16 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux服务器]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[分区]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[硬盘]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=240</guid>
		<description><![CDATA[（以下内容整理自《Linux服务器性能调整》）Linux至少需要一个root分区和一个swap分区，这两个分区以及其他需要频繁访问的分区在磁盘上的安装位置最终会影响到系统的性能。关于这些系统分区的安装位置，下面给出一些可以充分利用磁盘物理属性的建议。 <a href="http://sillydong.com/myserver/proposal-for-full-use-of-disk-properties.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>（以下内容整理自《Linux服务器性能调整》）Linux至少需要一个root分区和一个swap分区，这两个分区以及其他需要频繁访问的分区在磁盘上的安装位置最终会影响到系统的性能。关于这些系统分区的安装位置，下面给出一些可以充分利用磁盘物理属性的建议。<span id="more-240"></span></p>
<p>当你只有一个硬盘驱动器时：</p>
<p>1、对于root、swap、/var、/usr和/home等分区，都分别使用单独的分区。</p>
<p>2、当今大多数硬盘驱动器的盘片在外侧磁道上封装的扇区要多于内侧磁道，因此，从外侧磁道上读取数据要快得多。通常将编号低的分区安装到外部磁道上（例如，/dev/hda1比/dev/hda3更接近硬盘驱动器的外侧边缘），因此首先放置需要经常访问的分区。</p>
<p>3、第一个分区应该是swap分区（用于优化内存交换操作）。</p>
<p>4、第二个分区应该是/var，因为日志记录会频繁地写入/var/log中。</p>
<p>5、下一个分区应该是/usr，因为基本的系统工具和命令都位于/usr中。</p>
<p>6、root分区和/home分区可以驻留在靠近硬盘驱动器末尾的位置。</p>
<p>当你在使用多个硬盘驱动器时：</p>
<p>1、将经常访问的分区安装到速度更快的硬盘驱动器上。</p>
<p>2、如果这些硬盘驱动器的性能相近，那么将常用的分区分别安装在不同的硬盘驱动器上。例如，将/var和/usr分区分别置于两个不同的硬盘驱动器上，而交换分区应该位于自己单独的硬盘驱动器上。</p>
<p>3、如果拥有多个性能相近的硬盘驱动器，就可以考虑采用RAID。</p>
<p>4、为了最大化总线吞吐率，应该将每个充当主设备的硬盘驱动器安放到I/O通道（例如，IDE）上。硬盘驱动器在不同I/O通道之间移动后，其设备名称会发生变化，因此需要对文件系统表（/etc/fstab）进行相应改动。如果对包含root或/boot分区的硬盘驱动器进行移动，那么还需要编辑/boot/grup/menu.lst文件。</p>
<p>以上内容摘自《Linux服务器性能调整》，这段摘录适用于希望充分利用自己硬盘物理属性的朋友，当中指出的几点比较有针对性并且做出了适当的解释。至于分区文件系统选择可以参考我另一篇转自LinuxEden的文章，其中有对各文件系统优缺点的分析。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2010 年 11 月 12 日 -- <a href="http://sillydong.com/myserver/shell-for-rsync.html" title="用rsync进行两机备份的shell脚本">用rsync进行两机备份的shell脚本</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myserver/arch-ssh-server.html" title="Arch Linux搭建SSH环境">Arch Linux搭建SSH环境</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myserver/proposal-for-full-use-of-disk-properties.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>再来一个横版的Conky配置</title>
		<link>http://sillydong.com/mylinux/conkyrc.html</link>
		<comments>http://sillydong.com/mylinux/conkyrc.html#comments</comments>
		<pubDate>Wed, 06 Oct 2010 12:40:29 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[arch]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[conkyrc]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=214</guid>
		<description><![CDATA[这个配置文件的内容与以前的一篇日志中我写的的配置包含系统信息基本相同，只是样式改为横条的，在我的桌面上配合我的壁纸挺合适的，比较好看。横条的写起来好麻烦，要调整文字的对其，费了好多时间。废话不多说，看我的配置。尊重原创，转载请说明出处。 <a href="http://sillydong.com/mylinux/conkyrc.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这个配置文件的内容与以前的一篇日志中我写的的配置包含系统信息基本相同，只是样式改为横条的，在我的桌面上配合我的壁纸挺合适的，比较好看。横条的写起来好麻烦，要调整文字的对其，费了好多时间。废话不多说，看我的配置。尊重原创，转载请说明出处。<span id="more-214"></span></p>
<div id="attachment_236" class="wp-caption aligncenter" style="width: 610px"><a rel="attachment wp-att-236" href="http://sillydong.com/mylinux/conkyrc.html/attachment/conky2"><img class="size-full wp-image-236" title="横版Conky" src="http://sillydong.com/wp-content/uploads/2010/10/conky2.jpg" alt="" width="600" height="337" /></a><p class="wp-caption-text">横版Conky</p></div>
<p>[bash]<br />
# By Chen Zhidong<br />
# Blog:http://sillydong.com<br />
# Email:njutczd+gmail.com</p>
<p>alignment bottom_middle<br />
background yes<br />
border_width 0<br />
cpu_avg_samples 2<br />
default_color white<br />
default_outline_color black<br />
default_shade_color black<br />
draw_borders no<br />
draw_graph_borders yes<br />
draw_outline no<br />
draw_shades no<br />
use_xft yes<br />
double_buffer yes<br />
xftfont 文泉驿等宽微米黑:size=11<br />
gap_x 0<br />
gap_y 0<br />
minimum_size 850 310<br />
net_avg_samples 2<br />
no_buffers yes<br />
out_to_console no<br />
out_to_stderr no<br />
extra_newline no<br />
own_window yes<br />
own_window_class Conky<br />
own_window_type desktop<br />
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager<br />
stippled_borders 0<br />
update_interval 1.0<br />
uppercase no<br />
use_spacer none<br />
show_graph_scale no<br />
show_graph_range no<br />
total_run_times 0</p>
<p>TEXT<br />
$alignc$nodename  $kernel  $machine ${time %T %x %a}<br />
$hr<br />
${goto 10}System Status${goto 310}Network Status${goto 610}Filesystem Status<br />
${goto 10}Uptime:${goto 150}$uptime${goto 310}Eth0:${goto 450}${addr eth0}${goto 610}Home:${goto 710}${fs_free /home/}/${fs_size /home/}<br />
${goto 10}RAM:${goto 150}$mem/$memmax${goto 340}Real:${goto 420}Down${goto 485}${downspeedf eth0}KB/S${goto 610}Doc:${goto 710}${fs_free /media/Doc}/${fs_size /media/Doc}<br />
${goto 10}Swap:${goto 70}${swapbar 10,60}${goto 150}$swap/$swapmax${goto 420}UP${goto 485}${upspeedf eth0}KB/S${goto 610}Pro:${goto 710}${fs_free /media/Pro}/${fs_size /media/Pro}<br />
${goto 10}CPU:${goto 70}CPU1${goto 130}${cpubar cpu1 10,60}${goto 220}${cpu cpu1}%${goto 340}Total:${goto 420}Down${goto 485}${totaldown eth0}${goto 610}Hack:${goto 710}${fs_free /media/Hack}/${fs_size /media/Hack}<br />
${goto 70}CPU2${goto 130}${cpubar cpu2 10,60}${goto 220}${cpu cpu2}%${goto 420}UP${goto 485}${totalup eth0}${goto 610}Sys:${goto 710}${fs_free /media/Sys}/${fs_size /media/Sys}<br />
${goto 10}${cpugraph cpu0 14,265 -t}${goto 310}Wlan0:${goto 450}${addr wlan0}${goto 610}/:${goto 710}${fs_free /}/${fs_size /}<br />
${goto 10}Battery:${goto 120}$battery_percent%${goto 180}$battery_time${goto 340}Real:${goto 420}Down${goto 485}${downspeedf wlan0}KB/S${goto 610}/var:${goto 710}${fs_free /var}/${fs_size /var}<br />
${goto 10}IP Address:${goto 140}${exec wget http://checkip.dyndns.org/ -q -O &#8211; | grep -Eo &#8216;\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>&#8216;}${goto 420}UP${goto 485}${upspeedf wlan0}KB/S${goto 610}/usr:${goto 710}${fs_free /usr}/${fs_size /usr}<br />
${goto 340}Total:${goto 420}Down${goto 485}${totaldown wlan0}${goto 610}/tmp:${goto 710}${fs_free /tmp}/${fs_size /tmp}<br />
${goto 420}UP${goto 485}${totalup wlan0}<br />
${goto 310}Detail Info:<br />
${goto 310}${wireless_essid wlan0}${goto 420}${wireless_link_qual_perc wlan0}%${goto 485}${wireless_mode wlan0}<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 09 月 23 日 -- <a href="http://sillydong.com/mylinux/awesome-conky.html" title="Arch下的Awesome桌面和Conky">Arch下的Awesome桌面和Conky</a></li><li>2010 年 10 月 02 日 -- <a href="http://sillydong.com/mylinux/awesome-desktop.html" title="以Awesome为基础打造一个强大桌面系统">以Awesome为基础打造一个强大桌面系统</a></li><li>2010 年 09 月 19 日 -- <a href="http://sillydong.com/mylinux/package-manager.html" title="Linux软件包管理器大比拼">Linux软件包管理器大比拼</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myserver/arch-ssh-server.html" title="Arch Linux搭建SSH环境">Arch Linux搭建SSH环境</a></li><li>2010 年 08 月 17 日 -- <a href="http://sillydong.com/mylinux/arch-installation-with-adsl.html" title="关于Arch安装非用ADSL不可的解决过程">关于Arch安装非用ADSL不可的解决过程</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/conkyrc.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>以Awesome为基础打造一个强大桌面系统</title>
		<link>http://sillydong.com/mylinux/awesome-desktop.html</link>
		<comments>http://sillydong.com/mylinux/awesome-desktop.html#comments</comments>
		<pubDate>Sat, 02 Oct 2010 01:49:09 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[arch]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[cairo]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[desktop environment]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tiller]]></category>
		<category><![CDATA[瓦片]]></category>
		<category><![CDATA[窗口管理]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=209</guid>
		<description><![CDATA[本文介绍的包皆基于Arch Linux发行版，并且此处介绍的软件是在安装好系统并且安装好X环境之后，比如如果你hal或者xorg或者显卡驱动还没装的话请先去把这些装上再安装这些桌面环境相关的。说明：以下提到的软件名字一律使用包名，这样读者看了需要安装的话可以直接使用这个名字，也省得我再多嘴一句说是什么包名，并且此处所说的包仅为主要包，其dependence问题由pacman来解决，其他发行版的朋友请留意自己所用系统的包依赖。 <a href="http://sillydong.com/mylinux/awesome-desktop.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>本文介绍的包皆基于Arch Linux发行版，并且此处介绍的软件是在安装好系统并且安装好X环境之后，比如如果你hal或者xorg或者显卡驱动还没装的话请先去把这些装上再安装这些桌面环境相关的。说明：以下提到的软件名字一律使用包名，这样读者看了需要安装的话可以直接使用这个名字，也省得我再多嘴一句说是什么包名，并且此处所说的包仅为主要包，其dependence问题由pacman来解决，其他发行版的朋友请留意自己所用系统的包依赖。<span id="more-209"></span></p>
<p>首先，使用awesome嘛，必然是要先把awesome装上的，然后配置一下，比如主题跟快捷键绑定之类的，完成后开始为它添砖加瓦。</p>
<p>1、库</p>
<p><strong>gtk gtk2</strong> 图形库，用于美化一些窗口的显示</p>
<p><strong>qt</strong> QT图形库，有些程序对这个库有需求，为避免不必要的麻烦，可以装上</p>
<p><strong>cairo</strong> 请注意这个东西！最新的1.10.0-2版会造成awesome无法启动，请用旧的1.8.10-1版。这个问题在我和朋友的电脑上都出现了，请一定留意！如果有需要，可以在pacman.conf中禁用cairo的更新。今天（2010年10月2日）用163的源更新之后会用<strong>cairo-xcb</strong>替代之，同时awesome也会更新，并且因为cairo-xcb与cairo冲突而卸载cairo，一切正常了。</p>
<p>2、网络工具</p>
<p><strong>chromium</strong> 这个不用多说，浏览器，可以说最近还是比较火的，插件也很多。</p>
<p><strong>firefox firefox-i18n</strong> 这个也不用说，用户范围很广的浏览器，不过3启动很慢，有点期待4，希望能见到一个不一样的火狐。</p>
<p><strong>xchat </strong>这个是用于irc聊天的，挺好的一软件。</p>
<p><strong>transmission-gtk</strong> 这个用于BT下载，轻量快速，挺好的。</p>
<p><strong>multiget</strong> 这个是类似迅雷等的下载软件，当然功能还不能达到迅雷那样，有待开发。</p>
<p><strong>amule</strong> Linux下的电驴下载。</p>
<p>3、编程开发</p>
<p><strong>jdk </strong>java开发必备，可以直接用pacman安装，不过有些镜像站点没有64位的包，还请留意，国内163的站点有。没有的话就去官网下个用命令装一下，不麻烦。装好之后别忘试试java相关命令能否执行。如果喜欢openjdk可以安装openjdk。</p>
<p><strong>eclipse</strong> 一个强大的IDE，除了java之外通过扩展可以开发很多其他语言的程序。</p>
<p><strong>geany</strong> C语言开发工具。</p>
<p>4、编辑器</p>
<p><strong>vim</strong> 这个不多说。</p>
<p><strong>gedit</strong> 这个还不错的编辑工具，挺喜欢的。</p>
<p>5、文件管理</p>
<p><strong>pcmanfm</strong> 文件管理器，比nautilus轻量，但是功能上就稍稍逊色一点。</p>
<p><strong>nautilus</strong> 强大的文件管理器，在awesome中打开时请注意要加上&#8211;no-desktop的参数，不然桌面就被毁了。</p>
<p><strong>file-roller</strong> 压缩文件管理用的，挺不错的，加上unrar、zip、unzip、p7zip、xz、arj、unace的支持。</p>
<p>6、多媒体</p>
<p><strong>rhythmbox</strong> 听音乐的，挺好的，还是比较喜欢的。它需要一个光盘刻录软件<strong>brasero</strong>，需要的话也可以装上。</p>
<p><strong>mplayer</strong> 看电影用，挺方便的。</p>
<p><strong>gimp</strong> 图片编辑，有人说是linux下的photoshop，何苦呢，gimp就是gimp，gimp有gimp的特色。据说新的版本可以选择不将窗口拆分开来，这样子对awesome也是件好事。</p>
<p><strong>gqview</strong> 比较轻量也比较易用，还可以，不过还是比较喜欢eog多一点。</p>
<p><strong>scrot</strong> 桌面截图软件，比<strong>gnome-util</strong>的截图功能上差一点（个人习惯，勿喷我）。</p>
<p>7、办公</p>
<p><strong>openoffice-base openoffice-zh-CN </strong>这个仅仅是为了编辑微软的文档而准备的，如果没必要就别装了，看着心烦……</p>
<p>8、安全工具</p>
<p><strong>ettercap</strong> 网络嗅探工具，可以用于ARP欺骗。</p>
<p><strong>wireshark</strong> 抓包工具，安装之后记得吧用户加入wireshark组。</p>
<p><strong>nmap</strong> 扫描工具，安装之后可以有zenmap图形化的扫描。</p>
<p><strong>gnu-netcat</strong> 网络数据包修改工具。</p>
<p><strong>john</strong> Hash密码破解工具。</p>
<p><strong>dsniff</strong> 网络嗅探，ARP欺骗。</p>
<p><strong>aircrack-ng</strong> 这个不用多说，破解无线加密的，对WEP几乎无敌。我还做了个专门的脚本，链接如下：<a href="http://sourceforge.net/projects/aircrackwep/" target="_blank">http://sourceforge.net/projects/aircrackwep/</a>。</p>
<p><strong>fcrackzip</strong> zip压缩包密码破解工具</p>
<p>9、系统管理</p>
<p><strong>rxvt-unicode</strong> 这就是传说中的urxvt，详细的说明请看我早先的日志，其中有配置文件示例，仅供参考。</p>
<p><strong>xscreensaver</strong> 用xscreensaver-demo配置好后添加到~/.xinitrc中，请加上参数-no-splash来去掉可恶的splash。</p>
<p><strong>gparted</strong> 磁盘管理用的，把optional dependence的各种文件系统支持一起装上的好。</p>
<p><strong>gnome-power-manager</strong> gnome的电源管理，还不错的东西，拿到awesome上用用也挺好的，在~/.xinitrc中启动它。</p>
<p><strong>conky </strong>这个可以实时显示系统运行状态，在我的日志中有具体安装方法及我的配置文件，仅供参考。</p>
<p><strong>ibus ibus-pinyin</strong> 一个不错的输入法，在awesome和urxvt下都挺好的。</p>
<p><strong>networkmanager network-manager-applet</strong> 这是网络管理的，最近不知为何不能记住无线密码，每次连接路由都要我输密码，狠麻烦。不过总的来说还是挺不错的。在/etc/rc.conf中启动networkmanager，在~/.xinitrc中添加nm-applet &amp;来让它开机运行，也可以通过awesome的配置文件rc.conf来启动它。</p>
<p>到这就差不多了，基本的使用已经满足了，有些个人需求方面的还请自行解决，这里旧不一一列出了。</p>
<p>多嘴一句：使用Awesome有风险，请记得给自己留条后路，比如可以准备个备用的桌面，这样出了问题也还有回旋的余地，不用拼死拼活想着怎么让awesome起死回生（如果起死回生无望的话）。</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 09 月 23 日 -- <a href="http://sillydong.com/mylinux/awesome-conky.html" title="Arch下的Awesome桌面和Conky">Arch下的Awesome桌面和Conky</a></li><li>2010 年 10 月 06 日 -- <a href="http://sillydong.com/mylinux/conkyrc.html" title="再来一个横版的Conky配置">再来一个横版的Conky配置</a></li><li>2010 年 09 月 19 日 -- <a href="http://sillydong.com/mylinux/package-manager.html" title="Linux软件包管理器大比拼">Linux软件包管理器大比拼</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myserver/arch-ssh-server.html" title="Arch Linux搭建SSH环境">Arch Linux搭建SSH环境</a></li><li>2010 年 08 月 17 日 -- <a href="http://sillydong.com/mylinux/arch-installation-with-adsl.html" title="关于Arch安装非用ADSL不可的解决过程">关于Arch安装非用ADSL不可的解决过程</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/awesome-desktop.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Bash脚本编程中的操作符简述</title>
		<link>http://sillydong.com/myshell/bash-operator.html</link>
		<comments>http://sillydong.com/myshell/bash-operator.html#comments</comments>
		<pubDate>Sun, 26 Sep 2010 14:27:58 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[operator]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Test Constructs]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=187</guid>
		<description><![CDATA[由于写Bash脚本时经常用到if这类的条件判断，而bash中的操作符跟C里面的有点大不一样，头开始还很不习惯，经常为了一个判断忙活上半天，于是找了点系统的资料看了下操作符相关的东西，简要罗列如下，希望对各位也有些许帮助。 <a href="http://sillydong.com/myshell/bash-operator.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>由于写Bash脚本时经常用到if这类的条件判断，而bash中的操作符跟C里面的有点大不一样，头开始还很不习惯，经常为了一个判断忙活上半天，于是找了点系统的资料看了下操作符相关的东西，简要罗列如下，希望对各位也有些许帮助。<span id="more-187"></span></p>
<p>[bash]<br />
文件测试：</p>
<p>-e 文件存在<br />
-a 文件存在（已弃用）<br />
-f 文件为一般文件，非目录或设备文件<br />
-s 文件大小不为0<br />
-d 这是一个目录<br />
-c 这是一个块设备<br />
-p 这个文件是一个管道<br />
-h 这是一个符号链接文件<br />
-L 这是一个符号链接<br />
-S 这是一个Socket<br />
-t 文件被关联到一个终端设备上<br />
-w 文件是否有可写权限<br />
-x 文件是否有可执行权限<br />
-g sgid标记被设置到文件或目录上<br />
-u suid标记被设置到文件或目录上<br />
-k 设置粘贴位置<br />
-O 判断自己是否文件拥有者<br />
-G 文件所属组是否与你的相同<br />
-N 从文件上次被读取到现在是否被修改过<br />
file1 -nt file2 file1是否比file2新<br />
file1 -et file2 file1和file2是否相同文件的硬链接<br />
! 非</p>
<p>整数比较:</p>
<p>-eq 等于 if [ "$a" -eq "$b" ]<br />
-ne 不等于 if [ "$a" -ne "$b" ]<br />
-gt 大于 if [ "$a" -gt "$b" ]<br />
-ge 大于等于 if [ "$a" -ge "$b" ]<br />
-lt 小于 if [ "$a" -lt "$b" ]<br />
-le 小于等于 if [ "$a" -le "$b" ]<br />
< 小于(在双括号中使用) (("$a" < "$b"))<br />
<= 小于等于(在双括号中使用) (("$a" <= "$b"))<br />
> 大于(在双括号中使用) ((“$a” > “$b”))<br />
>= 大于等于(在双括号中使用) ((“$a” >= “$b”))</p>
<p>字符串比较:</p>
<p>= 等于 if [ "$a" = "$b" ]<br />
== 等于,与=等价 if [ "$a" == "$b" ]<br />
==比较操作符在双中括号对和单中括号对中的行为是不同的.<br />
  1 [[ $a == z* ]]    # 如果$a以”z”开头(模式匹配)那么结果将为真<br />
  2 [[ $a == "z*" ]]  # 如果$a与z*相等(就是字面意思完全一样), 那么结果为真.<br />
  3 [ $a == z* ]      # 文件扩展匹配(file globbing)和单词分割有效.<br />
  4 [ "$a" == "z*" ]  # 如果$a与z*相等(就是字面意思完全一样), 那么结果为真.<br />
!= 不等号,将在[[ ... ]]结构中使用模式匹配 if [ "$a" != "$b" ]<br />
< 小于, 按照ASCII字符进行排序 if [[ "$a" < "$b" ]]"<"<br />
  使用在[ ]结构中的时候需要被转义 if [ "$a" \< "$b" ]<br />
> 大于, 按照ASCII字符进行排序 if [[ "$a" > "$b" ]]<br />
  “>”使用在[ ]结构中的时候需要被转义 if [ "$a" \> "$b" ]<br />
-z 字符串为”null”, 意思就是字符串长度为零<br />
-n 字符串不为”null”.<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 07 月 22 日 -- <a href="http://sillydong.com/myshell/dot-file-show-hide.html" title="苹果系统显示隐藏文件切换脚本">苹果系统显示隐藏文件切换脚本</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myserver/clean-black-chain.html" title="分享一个Linux上清除黑链的脚本">分享一个Linux上清除黑链的脚本</a></li><li>2010 年 11 月 23 日 -- <a href="http://sillydong.com/myserver/service-monitor-shell.html" title="服务器服务监测脚本">服务器服务监测脚本</a></li><li>2012 年 03 月 26 日 -- <a href="http://sillydong.com/myserver/iptables-management-shell.html" title="简单高效的iptables管理shell脚本">简单高效的iptables管理shell脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/myshell/bash-operator.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 创始人给中国开源爱好者的视频</title>
		<link>http://sillydong.com/mylife/ubuntu-leader-to-chinese.html</link>
		<comments>http://sillydong.com/mylife/ubuntu-leader-to-chinese.html#comments</comments>
		<pubDate>Fri, 24 Sep 2010 02:23:53 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[mark]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[中国开源]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=178</guid>
		<description><![CDATA[通常每年的 9月份第三个周六是一年一度的自由软件日，今年的活动日则在 9月18-19日召开。在此次活动日上，Ubuntu 创始人 Mark Shuttleworth 博士通过视频发言给中国开源爱好者表达了他的意愿。同时值得兴奋的是，在此视频中他还透露，在即将发行的Ubuntu10.10中，Ubuntu 已将中文作为官方语言。据悉，Mark 非常关注中国开源软件的发展，曾屡次访华，应邀出席包括一年一度的开源中国开源世界，开源盛会。发言中Mark还提及在中国设立的办事处，并邀请开源爱好者参加。 <a href="http://sillydong.com/mylife/ubuntu-leader-to-chinese.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>通常每年的 9月份第三个周六是一年一度的自由软件日，今年的活动日则在 9月18-19日召开。在此次活动日上，Ubuntu 创始人 Mark Shuttleworth 博士通过视频发言给中国开源爱好者表达了他的意愿。同时值得兴奋的是，在此视频中他还透露，在即将发行的Ubuntu10.10中，Ubuntu 已将中文作为官方语言。据悉，Mark 非常关注中国开源软件的发展，曾屡次访华，应邀出席包括一年一度的开源中国开源世界，开源盛会。发言中Mark还提及在中国设立的办事处，并邀请开源爱好者参加。<span id="more-178"></span></p>
<p style="text-align: center;">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.tudou.com/v/BT-yVysfF1M/&amp;clickNavigateURL=http://www.tudou.com/programs/view/BT-yVysfF1M/&amp;withAD=flase/v.swf" /><param name="wmode" value="opaque" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="400" src="http://www.tudou.com/v/BT-yVysfF1M/&amp;clickNavigateURL=http://www.tudou.com/programs/view/BT-yVysfF1M/&amp;withAD=flase/v.swf" allowfullscreen="true" wmode="opaque"></embed></object></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 09 月 21 日 -- <a href="http://sillydong.com/mylife/top-50-opensource-blogs.html" title="最棒的50个开源博客">最棒的50个开源博客</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylife/ubuntu-leader-to-chinese.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arch下的Awesome桌面和Conky</title>
		<link>http://sillydong.com/mylinux/awesome-conky.html</link>
		<comments>http://sillydong.com/mylinux/awesome-conky.html#comments</comments>
		<pubDate>Thu, 23 Sep 2010 13:54:34 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[arch]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[conkyrc]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[desktop environment]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[pcmanfm]]></category>
		<category><![CDATA[rc.lua]]></category>
		<category><![CDATA[window manager]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=151</guid>
		<description><![CDATA[最近用Awesome比较爽，轻量快速，瓦片窗口，用起来挺舒服的。同时开多个终端互不干扰，能提高工作效率，写东西方便多了。配置稍显麻烦，不过也只要在原来配置文件基础上稍加修改就能达到想要的效果了。在Awesome中开个conky查看系统状态是个很好的选择。本文将介绍我的conkyrc文件，附带Awesome中的几个小技巧。 <a href="http://sillydong.com/mylinux/awesome-conky.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近用Awesome比较爽，轻量快速，瓦片窗口，用起来挺舒服的。同时开多个终端互不干扰，能提高工作效率，写东西方便多了。配置稍显麻烦，不过也只要在原来配置文件基础上稍加修改就能达到想要的效果了。在Awesome中开个conky查看系统状态是个很好的选择。本文将介绍我的conkyrc文件，附带Awesome中的几个小技巧。<span id="more-151"></span><div id="attachment_168" class="wp-caption alignright" style="width: 168px"><a rel="attachment wp-att-168" href="http://sillydong.com/mylinux/awesome-conky.html/attachment/conky"><img class="size-medium wp-image-168" title="conky in my awesome" src="http://sillydong.com/wp-content/uploads/2010/09/conky-158x300.jpg" alt="" width="158" height="300" /></a><p class="wp-caption-text">我awesome上的conky</p></div></p>
<p>先讲Awesome的小技巧。第一个：在Awesome下看窗口的class本来的快捷键没用了，后来了解到用命令”xprop”就可以看到窗口class，在终端中执行命令后，鼠标图标变成一个十字，移动十字光标到要查看的窗口上左击，终端中就显示窗口的信息，找到﻿﻿WM_CLASS(STRING)后面的内容就是了。找到之后将它写进awesome的rc.lua中，设置属性，就行了。不过这个设置对于eclipse似乎不起效果。eclipse启动画面还是很多个铺满桌面，加载完成之后的窗口倒是正常的。这个启动画面的问题我还不知道怎么解决。</p>
<p>第二个：用nautilus的朋友在awesome下打开时可能会出现把gnome中桌面带过来的情况，解决办法很简单，在启动nautilus的时候，不管是在awesome菜单中建了nautilus的项还是其他怎样，只要在nautilus的命令后加上参数”&#8211;no-desktop”来用就不会把桌面带过来。在awesome中nautilus的垃圾箱也是无效的，不止nautilus如此，pcmanfm也一样。</p>
<p>下面是本文的重点，conkyrc文件。由于Conky在gnome下不能正常用，与nautilus的desktop会冲突。在gnome下如果要使用conky也不是不可以，只要在gconf中将apps下nautilus中的preferences里show_desktop选项中的勾去掉，这时可以看到桌面上文件什么都没了，也就是桌面就没了，而此时conky正常显示。如果可以接受这种情况那就改吧。我无法接受，所以在gnome下就不开conky……废话不多说，下面是截图和~/.conkyrc，点击图片可以查看清晰大图：</p>
<p>[bash]<br />
background yes<br />
use_xft yes<br />
xftfont 文泉驿微米黑:size=10<br />
xftalpha 1<br />
update_interval 1.0<br />
total_run_times 0<br />
out_to_console no<br />
out_to_stderr no<br />
own_window yes<br />
own_window_transparent yes<br />
own_window_type desktop<br />
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager<br />
double_buffer yes<br />
minimum_size 280 280<br />
maximum_width 300<br />
draw_shades no<br />
draw_outline no<br />
draw_borders no<br />
draw_graph_borders yes<br />
default_color white<br />
default_shade_color black<br />
default_outline_color black<br />
alignment top_right<br />
gap_x 30<br />
gap_y 80<br />
no_buffers yes<br />
cpu_avg_samples 2<br />
override_utf8_locale no<br />
total_run_times 0</p>
<p>TEXT<br />
$alignc$nodename  $kernel  $machine<br />
$alignc${time %T %x %a}<br />
$hr<br />
System Status:<br />
Uptime:$alignr$uptime<br />
RAM:$alignr$mem/$memmax<br />
${memgraph 20}<br />
Swap Usage:   ${swapbar 6,60}$alignr$swap/$swapmax<br />
CPU:       CPU1  ${cpubar cpu1 6,100}$alignr${cpu cpu1}%<br />
               CPU2  ${cpubar cpu2 6,100}$alignr${cpu cpu2}%<br />
${cpugraph cpu0 20 -t}<br />
Battery:$alignc$battery_percent%$alignr$battery_time<br />
$hr<br />
Network Status:<br />
IP address:$alignr${exec wget http://checkip.dyndns.org/ -q -O &#8211; | grep -Eo &#8216;\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>&#8216;}<br />
${if_up eth0}eth0:$alignr${addr eth0}<br />
Real:$alignc Down $alignr ${downspeedf eth0}KB/s<br />
$alignc UP $alignr${upspeedf eth0}KB/s<br />
Total:$alignc Down $alignr${totaldown eth0}<br />
$alignc UP $alignr${totalup eth0}$endif<br />
${if_up wlan0}wlan0:$alignr${addr wlan0}<br />
Real:$alignc Down $alignr${downspeedf wlan0}KB/s<br />
$alignc UP $alignr${upspeedf wlan0}KB/s<br />
Total:$alignc Down $alignr${totaldown wlan0}<br />
$alignc UP $alignr${totalup wlan0}<br />
Detail Info:<br />
${wireless_essid wlan0}$alignc${wireless_link_qual_perc wlan0}%$alignr${wireless_mode wlan0}$endif<br />
$hr<br />
File System Status:<br />
Home:$alignr${fs_free /home/sillydong}/${fs_size /home/sillydong}<br />
Doc:$alignr${fs_free /media/Doc}/${fs_size /media/Doc}<br />
Pro:$alignr${fs_free /media/Pro}/${fs_size /media/Pro}<br />
Hack:$alignr${fs_free /media/Hack}/${fs_size /media/Hack}<br />
/usr:$alignr${fs_free /usr}/${fs_size /usr}<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 10 月 06 日 -- <a href="http://sillydong.com/mylinux/conkyrc.html" title="再来一个横版的Conky配置">再来一个横版的Conky配置</a></li><li>2010 年 10 月 02 日 -- <a href="http://sillydong.com/mylinux/awesome-desktop.html" title="以Awesome为基础打造一个强大桌面系统">以Awesome为基础打造一个强大桌面系统</a></li><li>2010 年 09 月 19 日 -- <a href="http://sillydong.com/mylinux/package-manager.html" title="Linux软件包管理器大比拼">Linux软件包管理器大比拼</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myserver/arch-ssh-server.html" title="Arch Linux搭建SSH环境">Arch Linux搭建SSH环境</a></li><li>2010 年 08 月 17 日 -- <a href="http://sillydong.com/mylinux/arch-installation-with-adsl.html" title="关于Arch安装非用ADSL不可的解决过程">关于Arch安装非用ADSL不可的解决过程</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/awesome-conky.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>最棒的50个开源博客</title>
		<link>http://sillydong.com/mylife/top-50-opensource-blogs.html</link>
		<comments>http://sillydong.com/mylife/top-50-opensource-blogs.html#comments</comments>
		<pubDate>Tue, 21 Sep 2010 03:06:47 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[开发]]></category>
		<category><![CDATA[开源]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=146</guid>
		<description><![CDATA[开源软件由庞大的社区提供支持，这个充满活力的社区造就了一批一流的博客。它们涵盖了从开源新闻，到最新发布的教程和黑客技巧的各个方面。
我们精选出这些博客，因为他们精通相关专业，不仅定期更新，而且还易于浏览，同时又非常实用。去看一看吧，您肯定会学好很多新东西的。 <a href="http://sillydong.com/mylife/top-50-opensource-blogs.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>开源软件由庞大的社区提供支持，这个充满活力的社区造就了一批一流的博客。它们涵盖了从开源新闻，到最新发布的教程和黑客技巧的各个方面。</p>
<p>我们精选出这些博客，因为他们精通相关专业，不仅定期更新，而且还易于浏览，同时又非常实用。去看一看吧，您肯定会学好很多新东西的。<span id="more-146"></span></p>
<p><strong>1. </strong><a href="http://www.rationalplanet.com/" target="blank"><strong>Alec Notes</strong></a><strong>：</strong></p>
<p>一个专注于Fedora Linux的简单博客。Alec是一名程序员，他精通PHP，mySQL和Javascript，同时还是一名Fedora Linux发烧友。他每解决一个工作上遇到的问题，就会在他的博客上发布一篇解决方案。他还关注新的软件开发。</p>
<p><strong>2. </strong><a href="http://linuxforpro.blogspot.com/" target="_blank"><strong>All you will need on linux</strong></a><strong>：</strong></p>
<p>这是一个Linux技巧博客。文章都是有关于作者所遇的具体问题的解决方法。</p>
<p><strong>3. </strong><a href="http://android-developers.blogspot.com/index.html" target="blank"><strong>Android Developers</strong></a><strong>：</strong></p>
<p>这个博客为Android编程人员提供了大量资源。里面包含了最新的Android新闻和更新提示。</p>
<p><strong>4. </strong><a href="http://biodegradablegeek.com/" target="blank"><strong>Biodegradable Geek</strong></a><strong>：</strong></p>
<p>这是一个开源编程爱好者的个人博客。</p>
<p><strong>5. </strong><a href="http://brightedges.blogspot.com/" target="blank"><strong>Bright Edges</strong></a><strong>：</strong></p>
<p>Bright Edges是一名工程系的学生，这是他的个人博客，其中包含了一些Linux/GNU技巧。</p>
<p><strong>6. </strong><a href="http://bsdpunk.blogspot.com/" target="blank"><strong>BSD Punk</strong></a><strong>：</strong></p>
<p>这是Tennessee网络顾问的个人博客，该网站经常发布一些有趣的Linux和其他开源语言的技巧和提示。他同时还发布一些他感兴趣的新闻。</p>
<p><strong>7. </strong><a href="http://www.clububuntu.com/" target="blank"><strong>Club Ubuntu</strong></a><strong>：</strong></p>
<p>Club Ubuntu提供了大量Ubuntu教程和信息。</p>
<p><strong>8. </strong><a href="http://www.dckap.com/blog/" target="blank"><strong>Dckap</strong></a><strong>：</strong></p>
<p>Dckap是一个技术服务公司，它同时还维护着一个关于开源和商业的博客。</p>
<p><strong>9. </strong><a href="http://www.duniadistro.net/" target="blank"><strong>Dedicated to Providing Quality Information on Linux and Distro</strong></a><strong>：</strong></p>
<p>就像它的名字一样，这个博客将提供有关Linux及其发行版的相关资讯。信息。</p>
<p><strong>10. </strong><a href="http://developerstation.blogspot.com/" target="_blank"><strong>Developer Station</strong></a><strong>：</strong></p>
<p>由计算机科学专业毕业生Rahul Kavi撰写，Developer Station包含了很多关于开源软件的技巧和提示，大部分为Python和Java相关。</p>
<p><strong>11. </strong><a href="http://www.development-cycle.com/" target="blank"><strong>Development Cycle</strong></a><strong>：</strong></p>
<p>Development Cycle由Australia的一名Linux管理员维护。他一般发布技巧和科技新闻。</p>
<p><strong>12. </strong><a href="http://www.earthinfo.org/" target="blank"><strong>Earth Info</strong></a><strong>：</strong></p>
<p>Earth Info是一个关于PHP和MySQL教程，技巧，新闻的博客。</p>
<p><strong>13. </strong><a href="http://foxbunny.tumblr.com/" target="blank"><strong>Fox Bunny&#8217;s Journal</strong></a><strong>：</strong></p>
<p>由Linux程序员和游戏设计师Branko Vukelic撰写，Fox Bunny&#8217;s Journal包含了很棒的技巧和教程。</p>
<p><strong>14. </strong><a href="http://freeware4review.blogspot.com/" target="_blank"><strong>Freeware 4 Review</strong></a><strong>：</strong></p>
<p>就像它说的名字，Freeware 4 Review对免费软件进行评论。</p>
<p><strong>15. </strong><a href="http://goinggnu.wordpress.com/" target="blank"><strong>Going GNU</strong></a><strong>：</strong></p>
<p>Going GNU由Shrinivasan撰写，他是一名Linux程序员，这个博客是他的每日体验。</p>
<p><strong>16. </strong><a href="http://www.howtoforge.com/" target="_blank"><strong>How to Forge</strong></a><strong>：</strong></p>
<p>这个博客提供Linux技术性教程。秉承真正开源内涵，任何人都可以参加贡献并使用使用它们。</p>
<p><strong>17. </strong><a href="http://blog.ibeentoubuntu.com/" target="blank"><strong>I&#8217; Been to Ubuntu</strong></a><strong>：</strong></p>
<p>这个博客提供Ubuntu和Debian的文字和视频教程。</p>
<p><strong>18. </strong><a href="http://www.internetling.com/" target="blank"><strong>Internetling</strong></a><strong>：</strong></p>
<p>Internetling是一个半个人的Linux新闻博客，提供Linux相关资讯。</p>
<p><strong>19. </strong><a href="http://javaforyou.wordpress.com/" target="blank"><strong>Java PitStop</strong></a><strong>：</strong></p>
<p>Java PitStop包含了非常实用的Java-specific新闻和信息。</p>
<p><strong>20. </strong><a href="http://larrythefreesoftwareguy.wordpress.com/about/" target="blank"><strong>Larry the Free Software Guy</strong></a><strong>：</strong></p>
<p>Larry是Open Source and Free Software Reporter的编辑和发布者。在他的博客里，他主要发布开源软件运动的相关新闻。</p>
<p><strong>21. </strong><a href="http://www.thelazysysadmin.net/" target="blank"><strong>The Lazy Sys Admin</strong></a><strong>：</strong></p>
<p>Lazy Sys Admin是一个关于Linux技巧和hack的博客，同时还包含一些博主所感兴趣的新闻事件。</p>
<p><strong>22. </strong><a href="http://indiaprab.blogspot.com/search/label/?max-results=20" target="blank"><strong>LiFunTech</strong></a><strong>：</strong></p>
<p>LiFunTech致力于查找并链接开源更新和应用程序。</p>
<p><strong>23. </strong><a href="http://linuxhug.blogspot.com/" target="blank"><strong>Linux Hug</strong></a><strong>：</strong></p>
<p>由Janith Bandara撰写，Linux Hug提供Linux技巧，教程和新闻。</p>
<p><strong>24. </strong><a href="http://www.linuxinsider.com/" target="blank"><strong>Linux Insider</strong></a><strong>：</strong></p>
<p>该博客由ECT News Network释出，它是最大的电子商务和科技新闻发布商之一。由数个人维护并发布有关于Linux社区的新闻，通常政治类和商业类要多于科技类。</p>
<p><strong>25. </strong><a href="http://www.linuxinsight.com/" target="blank"><strong>Linux Insight</strong></a><strong>：</strong></p>
<p>Linux Insight提供Linux科技性技巧和教程。</p>
<p><strong>26. </strong><a href="http://www.linux-masters.com/" target="blank"><strong>Linux Masters Blog</strong></a><strong>：</strong></p>
<p>Linux Masters专注于Linux和Linux发行版教程，大部分是Ubuntu。</p>
<p><strong>27. </strong><a href="http://www.linuxtoday.com/" target="blank"><strong>Linux Today</strong></a><strong>：</strong></p>
<p>Linux Today是一个热衷于开源新闻的博客。</p>
<p><strong>28. </strong><a href="http://www.linux.com/news/featured-blogs" target="blank"><strong>Linux.com Blog</strong></a><strong>：</strong></p>
<p>由Linux Foundation维护的非盈利博客，致力于促进Linux的发展。有数位作者发布Linux新闻。</p>
<p><strong>29. </strong><a href="http://blog.adityapatawari.com/" target="blank"><strong>Looking for the Source Code of Life</strong></a><strong>：</strong></p>
<p>由程序序员Aditya Patawari开设，Looking for the Source Code of Life提供Linux及Linux发行版的技巧和教程。</p>
<p><strong>30. </strong><a href="http://www.cyberciti.biz/" target="blank"><strong>nixCraft</strong></a><strong>：</strong></p>
<p>由Unix系统管理员Vivek Gite撰写，nixCraft提供丰富的Linux技巧，教程和新闻资讯。</p>
<p><strong>31. </strong><a href="http://www.linux-magazine.com/Online/Blogs/Off-the-Beat-Bruce-Byfield-s-Blog" target="blank"><strong>Off the Beat</strong></a><strong>：</strong></p>
<p>Bruce Byfield为Linux Magazine撰文。他的博客主要包含开源社区新闻。</p>
<p><strong>32. </strong><a href="http://omgubuntu.co.uk/" target="blank"><strong>OMG! Ubuntu!</strong></a><strong>：</p>
<p></strong>OMG! Ubuntu!发布与Ubuntu相关的新闻，文章，访谈和技巧。</p>
<p><strong>33. </strong><a href="http://bizcoach.blogspot.com/" target="blank"><strong>Open Business</strong></a><strong>：</p>
<p></strong>Open Business专注于开源技术为人类商业活动造成的影响的相关新闻。</p>
<p><strong>34. </strong><a href="http://news.cnet.com/openroad/" target="_blank"><strong>The Open Road</strong></a><strong>：</strong></p>
<p>这个博客是CNET的一部分，由Matt Asay维护，他是一名领先的开源商务战略家。他以易于理解的方式，全面探讨开源战略和政治。</p>
<p><strong>35. </strong><a href="http://www.businessreviewonline.com/os/" target="_blank"><strong>Open Source Business News</strong></a><strong>：</strong></p>
<p>Open Source Business Review包含了开源商业社区的相关新闻。</p>
<p><strong>36. </strong><a href="http://open-source-development.blogspot.com/" target="_blank"><strong>Open Source Development</strong></a><strong>：</strong></p>
<p>Open Source Development关注开源技术的最新更新。它强调电子商务的创新。</p>
<p><strong>37. </strong><a href="http://ordinarytux.wordpress.com/" target="blank"><strong>Ordinary Tux</strong></a><strong>：</strong></p>
<p>Ordinary Tux发布Linux，Android和其他开源技术的相关教程和技巧提示。</p>
<p><strong>38. </strong><a href="http://davidsiegel.org/" target="_blank"><strong>The Plenitude of Arboreal Beauty</strong></a><strong>：</strong></p>
<p>由程序员David Siegel撰写，PAB包含了各种开源话题。</p>
<p><strong>39. </strong><a href="http://reboltutorial.com/" target="blank"><strong>Rebol Tutorial</strong></a><strong> ：</strong></p>
<p>Rebol Tutorial提供Rebol的编程技巧和提示。</p>
<p><strong>40. </strong><a href="http://rhel5certs.blogspot.com/" target="_blank"><strong>Red Hat Enterprises</strong></a><strong>：</p>
<p></strong>Red Hat Enterprises是一个关于Red Hat&#8217;s Linux事件更新的博客。</p>
<p><strong>41. </strong><a href="http://www.revoltwebdesign.com/blog.html" target="blank"><strong>Revolt</strong></a><strong>：</strong></p>
<p>Revolt提供开源和网页开发软件的更新资讯。</p>
<p><strong>42. </strong><a href="http://slashdot.org/" target="_blank"><strong>Slashdot</strong></a><strong>：</strong></p>
<p>它的口号就说明了一切：News for Nerds Stuff That Matters。这个博客覆盖了各种开发主题，主要专注于Linux和开放软件。</p>
<p><strong>43. </strong><a href="http://www.delphigeist.com/" target="_blank"><strong>The Spirit of Delphi</strong></a><strong>：</strong></p>
<p>The Spirit of Delphi提供了Delphi，C#，C++，Ruby，Python和Java编程的技巧和教程。同时还包含了一些关于软件管理的通用技巧和提示，以及与作者工作有关的其他科技工作。</p>
<p><strong>44. </strong><a href="http://www.stefanolaguardia.eu/en/" target="blank"><strong>Stefano Laguardia</strong></a><strong>：</strong></p>
<p>Stefano Laguardia是有个有趣的博客，它提供与法律焦点的开源新闻。</p>
<p><strong>45. </strong><a href="http://ownedboxes.blogspot.com/" target="blank"><strong>Tech Stuff</strong></a><strong>：</strong></p>
<p>您可以通过Tech Stuff下载很多非常棒的开源程序，有时也发布一些很棒的技巧提示和hack。</p>
<p><strong>46. </strong><a href="http://pankajdangi.com/" target="blank"><strong>Technical Zone</strong></a><strong>：</strong></p>
<p>Technical Zone是查找犀利评论以及最新软件概要的好地方。</p>
<p><strong>47. </strong><a href="http://basicslinux.blogspot.com/" target="blank"><strong>Things You Should Know About Linux!</strong></a><strong>：</strong></p>
<p>Thins You Should Know About Linux提供与Linux相关的新闻。</p>
<p><strong>48. </strong><a href="http://cviorel.easyblog.ro/" target="blank"><strong>Ubuntu!</strong></a><strong>：</strong></p>
<p>Ubuntu!是一个提供Ubuntu技巧，提示和教程的博客。</p>
<p><strong>49. </strong><a href="http://www.virtfoundry.com/blog/" target="_blank"><strong>VirtFoundry</strong></a><strong>：</strong></p>
<p>VirtFoundry是一个关于Linux，系统管理和虚拟化的博客。它主要聚焦于Linux技巧和提示。</p>
<p><strong>50. </strong><a href="http://webmaster-software.blogspot.com/" target="_blank"><strong>WebMasters Software</strong></a><strong>：</strong></p>
<p>WebMaster Software关注开源软件开发，特别是基于手机和网络的。 </p>
<p>原文链接：<a href="http://www.distrolist.com/top-50-open-source-blogs/">http://www.distrolist.com/top-50-open-source-blogs/</a></p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 15 日 -- <a href="http://sillydong.com/myserver/linux-find-shell.html" title="简单化Linux下find操作的脚本分享">简单化Linux下find操作的脚本分享</a></li><li>2011 年 05 月 12 日 -- <a href="http://sillydong.com/myjava/android-tabwidget.html" title="Android美化TabWidget详细代码">Android美化TabWidget详细代码</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylife/top-50-opensource-blogs.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>URXVT配置，包括色彩及字体设置</title>
		<link>http://sillydong.com/mylinux/urxvt.html</link>
		<comments>http://sillydong.com/mylinux/urxvt.html#comments</comments>
		<pubDate>Sun, 19 Sep 2010 14:32:00 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[rxvt]]></category>
		<category><![CDATA[urxvt]]></category>
		<category><![CDATA[Xdefaults]]></category>
		<category><![CDATA[透明]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=96</guid>
		<description><![CDATA[这段东西是用于配置URXVT，即RXVT-Unicode。这是一个强大的终端模拟，但是配置起来稍显麻烦。在经历了无数次失败之后，小生终于将它配置得像样了，不敢私藏，拿出来与大家分享。 <a href="http://sillydong.com/mylinux/urxvt.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这段东西是用于配置URXVT，即RXVT-Unicode。这是一个强大的终端模拟，但是配置起来稍显麻烦。在经历了无数次失败之后，小生终于将它配置得像样了，不敢私藏，拿出来与大家分享。</p>
<p>这个配置文件实现效果包括：透明背景，使用9号文泉驿等宽正黑，色彩输出，中文输入（这个配置文件里面的是ibus，请根据您电脑的实际情况调整输入法）。实际效果如下图：<span id="more-96"></span></p>
<div id="attachment_135" class="wp-caption aligncenter" style="width: 610px"><a href="http://sillydong.com/mylinux/urxvt.html/attachment/urxvt-2" rel="attachment wp-att-135"><img src="http://sillydong.com/wp-content/uploads/2010/09/urxvt.jpg" alt="" title="urxvt" width="600" height="444" class="size-full wp-image-135" /></a><p class="wp-caption-text">我的URXVT外观</p></div>
<p>[bash]<br />
!!$HOME/.Xdefaults<br />
URxvt.preeditType:Root<br />
!!调整此处设置输入法<br />
URxvt.inputMethod:ibus<br />
!!颜色设置<br />
URxvt.depth:32<br />
!!中括号内数表示透明度<br />
URxvt.background: [90]#000000<br />
URxvt.foreground:  #ffffff<br />
URxvt.colorBD:Gray95<br />
URxvt.colorUL:Green<br />
URxvt.color1:Red2<br />
URxvt.color4:RoyalBlue<br />
URxvt.color5:Magenta2<br />
URxvt.color8:Gray50<br />
URxvt.color10:Green2<br />
URxvt.color12:DodgerBlue<br />
URxvt.color14:Cyan2<br />
URxvt.color15:Gray95<br />
!!URL操作<br />
URxvt.urlLauncher:chromium<br />
URxvt.matcher.button:1<br />
Urxvt.perl-ext-common:matcher<br />
!!滚动条设置<br />
URxvt.scrollBar:True<br />
URxvt.scrollBar_right:True<br />
URxvt.scrollBar_floating:False<br />
URxvt.scrollstyle:plain<br />
!!滚屏设置<br />
URxvt.mouseWheelScrollPage:True<br />
URxvt.scrollTtyOutput: False<br />
URxvt.scrollWithBuffer: True<br />
URxvt.scrollTtyKeypress: True<br />
!!光标闪烁<br />
URxvt.cursorBlink:True<br />
URxvt.saveLines:3000<br />
!!边框<br />
URxvt.borderLess:      False<br />
!!字体设置<br />
Xft.dpi:96<br />
URxvt.font:xft:文泉驿等宽正黑:size=9:style=Regular:antialias=true,xft:文泉驿等宽正黑:size=8:style=Regular:antialias=true<br />
URxvt.boldfont:xft:文泉驿等宽正黑:size=9:style=BOld:antialias=true,xft:文泉驿等宽正黑:size=8:style=Bold:antialias=true<br />
[/bash]</p>
<p>附vim配置~/.vimrc一份：</p>
<p>[bash]<br />
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936<br />
set bg=dark<br />
colorscheme pablo<br />
set nu<br />
set hlsearch<br />
set backspace=2<br />
set autoindent<br />
set ruler<br />
set showmode<br />
syntax on<br />
set tabstop=4<br />
set history=50<br />
set nolinebreak<br />
set backspace=indent,eol,start<br />
set t_Co=256<br />
[/bash]</p>
<h3  class="related_post_title">随机日志：</h3><ul class="related_post"><li>2012 年 03 月 12 日 -- <a href="http://sillydong.com/myshell/shell-validate-ip-bas.html" title="Shell下判断输入是否合法IP">Shell下判断输入是否合法IP</a></li><li>2011 年 08 月 23 日 -- <a href="http://sillydong.com/myserver/tar-backup.html" title="通用Linux服务器备份打包脚本">通用Linux服务器备份打包脚本</a></li><li>2011 年 12 月 26 日 -- <a href="http://sillydong.com/myjava/android-md5-base64-encode-decode.html" title="Android MD5加密类和Base64编解码类">Android MD5加密类和Base64编解码类</a></li><li>2011 年 05 月 08 日 -- <a href="http://sillydong.com/myjava/android-activity-finish.html" title="Android关闭所有Activity完全退出程序">Android关闭所有Activity完全退出程序</a></li><li>2011 年 12 月 20 日 -- <a href="http://sillydong.com/myjava/android-inputstream-string-json.html" title="Android Java InputStream处理相关代码">Android Java InputStream处理相关代码</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/urxvt.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux软件包管理器大比拼</title>
		<link>http://sillydong.com/mylinux/package-manager.html</link>
		<comments>http://sillydong.com/mylinux/package-manager.html#comments</comments>
		<pubDate>Sun, 19 Sep 2010 13:46:11 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[arch]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dep]]></category>
		<category><![CDATA[dpkg]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[pacman]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[rpm]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=123</guid>
		<description><![CDATA[Linux各种发行版我也体验了不少，给我的感觉就是每个发行版都是差不多的，除了各自的系统架构和软件包管理器不同。系统架构也可以归结到软件包管理上，不同的软件包搭出来的系统自然不一样。所以归根到底，用好一个发行版首先要掌握它的软件包管理器，尤其是它的命令。本文整理了一下各类软件包管理器的命令，看看学学，挺好。 <a href="http://sillydong.com/mylinux/package-manager.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Linux各种发行版我也体验了不少，给我的感觉就是每个发行版都是差不多的，除了各自的系统架构和软件包管理器不同。系统架构也可以归结到软件包管理上，不同的软件包搭出来的系统自然不一样。所以归根到底，用好一个发行版首先要掌握它的软件包管理器，尤其是它的命令。本文整理了一下各类软件包管理器的命令，看看学学，挺好。<span id="more-123"></span></p>
<p>说明：第一页是pacman(Arch Linux)，第二页将rpm命令与dpkg命令做个对比，第三页则是yum与apt-get的对比。</p>
<p>首推Arch Linux的pacman，这是个好东西，用了你就知道。废话不多说，看下面的介绍（来自Arch Wiki）。</p>
<p>[bash]<br />
安装或者升级单个软件包，或者一列软件包（包含依赖包），使用如下命令：<br />
pacman -S package_name1 package_name2<br />
有时候在不同的软件仓库中，一个软件包有多个版本（比如extra和testing）。你可以选择一个来安装：<br />
pacman -S extra/package_name<br />
pacman -S testing/package_name<br />
删除单个软件包，保留其全部已经安装的依赖关系<br />
pacman -R package_name<br />
删除指定软件包，及其所有没有被其他已安装软件包使用的依赖关系：<br />
pacman -Rs package_name<br />
缺省的，pacman会备份被删除程序的配置文件，将它们加上*.pacsave扩展名。如果你在删除软件包时要同时删除相应的配置文件（这种行为在基于Debian的系统中称为清除purging），你可是使用命令：<br />
pacman -Rn package_name<br />
当然，它也可以加上-s参数来删除当前无用的依赖。这样的话，真正删除一个软件包、它的配置文件以及所有不再需要的依赖的命令如下：<br />
pacman -Rsn package_name<br />
注意！Pacman不会删除软件包安装后才创建的配置文件。你可以从你的home文件夹中手动删除它们。</p>
<p>Pacman能够只用一个指令来升级系统中所有已安装的包。升级的时间取决于你的系统有多新。<br />
pacman -Su<br />
当然，最好做法的是将升级系统和同步仓库数据合成为一条指令：<br />
pacman -Syu<br />
查询包数据库<br />
Pacman可以在包数据库中查询软件包，查询位置包含了包的名字和描述：<br />
pacman -Ss keywords<br />
要查询已安装的软件包：<br />
pacman -Qs keywords<br />
一旦你得到了软件包的完整名字，你可以获取关于它的更为详尽的信息：<br />
pacman -Si package_name<br />
pacman -Qi package_name<br />
要获取已安装软件包所包含文件的列表：<br />
pacman -Ql package_name<br />
你也可以通过查询数据库获知目前你的文件系统中某个文件是属于哪个软件包。<br />
pacman -Qo /path/to/a/file<br />
要罗列所有不再作为依赖的软件包(孤立orphans)：<br />
pacman -Qdt<br />
Pacman使用-Q参数来查询本地软件包数据库。参见：<br />
pacman -Q &#8211;help<br />
&#8230;而使用-S参数来查询远程同步的数据库。参见：<br />
pacman -S &#8211;help<br />
详情可参见pacman(8) manpage。</p>
<p>Pacman是个非常广泛的包管理工具，这里只是它的一些其它主要特性。<br />
下载包而不安装它：<br />
pacman -Sw package_name<br />
安装一个&#8217;本地&#8217;包（不从源里）：<br />
pacman -U /path/to/package/file.pkg.tar.gz<br />
安装一个&#8217;远程&#8217;包（不从源里）：<br />
pacman -U http://url/file.pkg.tar.gz<br />
清理当前未被安装软件包的缓存(/var/cache/pacman/pkg):<br />
pacman -Sc<br />
完全清理包缓存：<br />
pacman -Scc<br />
Warning: 关于pacman -Scc，仅在你确定不需要做任何软件包降级工作时才这样做。pacman -Scc会从缓存中删除所有软件包。<br />
要删除孤立软件包（递归的，要小心)：<br />
pacman -Rs $(pacman -Qtdq)<br />
重新安装你系统中所有的软件包（仓库中已有的）：<br />
pacman -S $(pacman -Qq | grep -v “$(pacman -Qmq)”)<br />
获取本地软件包和它们大小的一个已排序清单列表：<br />
LANG=C pacman -Qi | sed -n &#8216;/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}&#8217; | sort -nk2<br />
要了解更详细的参数开关可以pacman &#8211;help或者man pacman。</p>
<p>Pacman的配置文件位于/etc/pacman.conf。关于配置文件的进一步信息可以用man pacman.conf查看。<br />
常用选项都在[options]段。阅读man手册或者查看缺省的pacman.conf可以获得有关信息和用途。<br />
如果由于某种原因，你不希望升级某个软件包，可以加入内容如下：<br />
IgnorePkg = 软件包名<br />
和软件包一样，你也可以象这样跳过升级某个软件包组：<br />
IgnoreGroup = gnome<br />
[/bash]</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2010 年 10 月 06 日 -- <a href="http://sillydong.com/mylinux/conkyrc.html" title="再来一个横版的Conky配置">再来一个横版的Conky配置</a></li><li>2010 年 10 月 02 日 -- <a href="http://sillydong.com/mylinux/awesome-desktop.html" title="以Awesome为基础打造一个强大桌面系统">以Awesome为基础打造一个强大桌面系统</a></li><li>2010 年 09 月 18 日 -- <a href="http://sillydong.com/myserver/arch-ssh-server.html" title="Arch Linux搭建SSH环境">Arch Linux搭建SSH环境</a></li><li>2010 年 08 月 17 日 -- <a href="http://sillydong.com/mylinux/arch-installation-with-adsl.html" title="关于Arch安装非用ADSL不可的解决过程">关于Arch安装非用ADSL不可的解决过程</a></li><li>2010 年 05 月 24 日 -- <a href="http://sillydong.com/myshell/shell-for-gedit.html" title="Gedit中编译C源代码并运行的外部工具脚本">Gedit中编译C源代码并运行的外部工具脚本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/package-manager.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux上照样下载迅雷、快车、超级旋风的资源</title>
		<link>http://sillydong.com/mylinux/thunder-flashget-storm.html</link>
		<comments>http://sillydong.com/mylinux/thunder-flashget-storm.html#comments</comments>
		<pubDate>Sun, 19 Sep 2010 06:21:36 +0000</pubDate>
		<dc:creator>Chen Zhidong</dc:creator>
				<category><![CDATA[Linux应用]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[flashget]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[stroem]]></category>
		<category><![CDATA[thunder]]></category>

		<guid isPermaLink="false">http://sillydong.com/?p=115</guid>
		<description><![CDATA[话说在Linux下上网想下东西时发现诸如“迅雷资源”、“快车资源”字样时候很讨厌！凭什么，明知道Linux下下载不用那些的，这可怎么办。网上据说是base64加密然后经过什么什么的出来的下载地址，找朋友深入了解了一下才知道的确是把下载地址经过base64加密之后加点字符出来的，这样就方便了。脚本一出，谁与争锋！所以有了下面的代码，不是直接放sh里面执行的，你要真想放进去也没事，就是麻烦您自己再组织一下语言。 <a href="http://sillydong.com/mylinux/thunder-flashget-storm.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>话说在Linux下上网想下东西时发现诸如“迅雷资源”、“快车资源”字样时候很讨厌！凭什么，明知道Linux下下载不用那些的，这可怎么办。网上据说是base64加密然后经过什么什么的出来的下载地址，找朋友深入了解了一下才知道的确是把下载地址经过base64加密之后加点字符出来的，这样就方便了。脚本一出，谁与争锋！所以有了下面的代码，不是直接放sh里面执行的，你要真想放进去也没事，就是麻烦您自己再组织一下语言。<span id="more-115"></span></p>
<p>事先声明：这不是对迅雷快车腾讯的挑战！只是出于技术目的，研究了一下。真正下载也不是非得去下迅雷资源快车资源旋风资源，网络这么大，也不一定非得下那些，是吧。拒绝跨省！</p>
<p>[bash]</p>
<p>迅雷：<br />
sed -n &#8216;/^thunder/p&#8217; test | sed &#8216;/^thunder/s/thunder\:\/\///&#8217; | base64 -d | sed &#8216;s/AA//&#8217; | sed &#8216;s/ZZ//&#8217;</p>
<p>快车：<br />
sed -n &#8216;/^flashget/p&#8217; test | sed &#8216;/^flashget/s/flashget\:\/\///&#8217; | base64 -d | sed &#8216;s/\[FLASHGET\]//&#8217; | sed &#8216;s/\[FLASHGET\]//&#8217;</p>
<p>旋风：<br />
sed -n &#8216;/^qqdl/p&#8217; test | sed &#8216;/^qqdl/s/qqdl\:\/\///&#8217; | base64 -d</p>
<p>[/bash]</p>
<p>其实快车现在已经有了linux版本，我尝试过。Arch上32位下可以使用，64位下不行，用AUR下的也不行，论坛里面的就不用说了。具体下载什么自己google去。^_^</p>
<h3  class="related_post_title">相关日志：</h3><ul class="related_post"><li>2012 年 03 月 15 日 -- <a href="http://sillydong.com/myserver/linux-find-shell.html" title="简单化Linux下find操作的脚本分享">简单化Linux下find操作的脚本分享</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/my-nagios-configuration-notes.html" title="我的Nagios安装配置笔记">我的Nagios安装配置笔记</a></li><li>2011 年 02 月 10 日 -- <a href="http://sillydong.com/myserver/new-service-monitor-shell.html" title="服务器服务监测脚本（更新）">服务器服务监测脚本（更新）</a></li><li>2011 年 02 月 09 日 -- <a href="http://sillydong.com/myserver/iptables-rules-summary.html" title="我的iptables总结">我的iptables总结</a></li><li>2010 年 12 月 22 日 -- <a href="http://sillydong.com/myshell/shell-fragments.html" title="分享一些有用的Shell脚本片段">分享一些有用的Shell脚本片段</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://sillydong.com/mylinux/thunder-flashget-storm.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

