Feeds:
文章
评论

Archive for 2009年七月月

rsync配置

安装脚本
#!/bin/sh
apt-get install rsync xinetd
sed -in-place -e s/RSYNC_ENABLE=false/RSYNC_ENABLE=inetd/ /etc/default/rsync
cp rsync /etc/xinetd.d/rsync
cp rsyncd.conf /etc/rsyncd.conf
cp rsyncd.secrets /etc/rsyncd.secrets
chmod 600 /etc/rsyncd.secrets
/etc/init.d/xinetd restart
配置文件内容如下:
rsync

service rsync
{
disable = no
socket_type = stream
wait = no
user [...]

Read Full Post »

如果代码文件里即有GBK又有UTF-8编码,且又没有enca的情况下,可以用shell,iconv,php稍微搞一下:
1)用PHP写一个测试文件编码的小程序
vi ~/bin/detect_encoding
#!/usr/bin/php -n
<?php
$file=fopen(‘php://stdin’,’r’);
$s = ”;
while (!feof($file)) {
$buffer = fgets($file,4096);
$s.=$buffer;
}
fclose($file);
echo mb_detect_encoding($s,”ASCII,UTF-8,GBK”);
2 )  找出所有GBK编码的文件:
for f in `find . -name “*.java”`; do ~/bin/detect_encoding < $f; echo ” $f”; done | grep CP936 | cut -b 6- > tmp_list
3)用iconv批量转
for i in `cat tmp_list`; do iconv -f GBK -t UTF-8 $i > tmp; mv tmp $i; done
–搞定–

Read Full Post »