把下面的 地址拷貝到 迅雷的下載地點:
基本格式
ftp://username:password@host:port/path/file
比如:
ftp://user:pass@118.85.xxx.x/ring_17000_QuanGuo_20090513.rar
Skynet---------- ---------- 我的新 blog : liukaiyi.cublog.cn ---------- ---------- |
把下面的 地址拷貝到 迅雷的下載地點: 基本格式 ftp://username:password@host:port/path/file 比如: ftp://user:pass@118.85.xxx.x/ring_17000_QuanGuo_20090513.rar 結合 windows ssh 搭建,你會知道更多 [轉] 配置cygwin下中文支持
版權聲明:轉載時請以超鏈接形式標明文章原始出處和作者信息及本聲明 配置cygwin來支持中文 http://my.opera.com/render/blog/show.dml/369483 Site From: http://ergophile.bokee.com/1145741.html Cygwin中文How-to- -I googled it. http://www.linuxeden.com/forum/blog/index.php?op=ViewArticle&articleId=567&blogId=110848 bamanzi | 28 九月, 2004 22:14 大致寫了一下,有待補充。
本來一年前就打算寫的,但后來覺得老黃寫更合適,但這家伙似乎只對代碼有興趣,總不寫文檔。 終端locale支持Cygwin的locale支持一直都不太好,采用zh_CN.gb2312好像問題很多,我一直采用的是zh_CN.gbk
~/.bashrc LC_CTYPE=zh_CN.gbk
CHARSET=GBK #(glib2需要使用找個環境變量確定文件名的編碼) export LC_CTYPE CHARSET 一些小問題允許bash輸入、輸出中文字符
~/.inputrc set convert-meta off
set input-meta on set output-meta on ls顯示中文文件名(而不是一堆問號) alias ls="/bin/ls --show-control-chars"
less瀏覽中文文件 less --raw-control-chars
另外LESSCHARSET環境變量也很有用
X下的中文支持locale支持Cygwin的locale支持一直都有問題,好在X程序還可以使用XLOCALE。
建議還是使用zh_CN.gbk, 不要使用zh_CN.GB2312 在移植程序時需要注意不要讓程序連接libcygwin.a里面的setlocale,而是采用libX11.a里面的_Xsetlocale。方法是:檢查被移植程序的全部源代碼,發現 #include
就修改為
#define X_LOCALE
#include 中文字體PCF點陣字體GTK1.x 和其他一些老的X程序都是用X字體,
注意必須要有編碼與locale一致的字體,比如用zh_CN.gbk就必須要由GBK編碼的字體,用zh_CN.GB2312就必須要有GB2312編碼的字體 如果使用zh_CN.GB2312,這里有一個RedOffice面帶的點陣字體包 可以采用ttf2bdf從TTF抽取得到bdf格式,然后再用bdf2pcf得到pcf格式的字體文件。 (這里有一個Windows版本的TTF2BDF,可以將Windows TTF字體轉換出BDF字體, 注意得到bdf后要手工編輯一下文件頭,將編碼聲明修改正確) 得 到字體之后,放到某個目錄下,執行mkfontdir生成fonts.dir,然后用xset +fp /path/to/your/fonts將字體路徑加入即可(注意與fontconfig的配置不同,這里路徑是不遞歸的,如果有的字體放在子目錄里面, 子目錄也需要添加進去才行)。 TTF字體很多新的應用程序(比如GTK2)都使用fontconfig/libxft2來顯示字體,它對TTF字體的支持比較好(X以前通過freetype, xft模塊也支持TTF字體,但對中日韓字體的支持不是太好,而且也在Cygwin下似乎也沒有這些模塊)
完全可以使用Linux下的arphic字體包. 如果沒有安裝Linux,可以到 ![]() 得到字體文件之后,放到某個目錄之下,編輯/etc/fonts/local.conf,將字體路徑加入: /path/to/my/ttf/fonts
如果只是自己使用,可以將字體文件放到~/.fonts下,不需要修改任何配置,最多三十秒fontconfig就能夠發現這些字體了。中文輸入法老黃(hzhr)移植了miniChinput到Cygwin,我也移植了fcitx-1.8.5和3.0,均可以從我的網站上找到 http://www.oliwen.com/bamanzi/cygwin/chinese/一般設置了LC_CTYPE和XMODIFIERS就可以在程序中激活輸入輸入法了(除非這個程序沒有XIM支持): LC_CTYPE=zh_CN.gbk
對于fcitx而言,XMODIFIERS設置為什么都可以(但必須要設置),所以設置為"@im=Chinput"的話chinput和fcitx都可以正常使用XMODIFIERS="@im=Chinput" export LC_CTYPE XMODIFIERS 結合 cygwin 解決 亂碼問題 (轉) 你會知道更多 參考 : http://www.docin.com/p-4534575.html
#關鍵字 python,pycurl, SGMLParser ,sqlite3, 抓取 , 增量計算,encodeuri 轉換,crontab ,mail #參考 sqlite3 http://linuxgazette.net/109/chirico1.html SGMLParser http://www.woodpecker.org.cn/diveintopython/html_processing/index.html 提取 python import pycurl
from sgmllib import SGMLParser import re from urllib import quote, unquote #使用 SGMLParser(html 分析) 類繼承 #詳細請查看 # http://www.woodpecker.org.cn/diveintopython/html_processing/index.html class BaiduTop_GMLParser(SGMLParser): def reset(self, verbose=0): SGMLParser.reset(self) self.data=[] self.a = None def start_a(self, attrs): href = [v for k, v in attrs if k=='href'] rsc=re.search('word=(.*)\+(.*)', href[0] ) if href and rsc : #baidu 頁面編碼為 gbk ,并且中文 encodeuri 了 #此轉換為 utf8 music=unquote(rsc.group(1)).decode('gbk').encode('utf8') actors=unquote(rsc.group(2)).decode('gbk').encode('utf8') self.data.append((actors,music)) self.a=True def getData(self): return self.data def __init__(self): self.reset() c = pycurl.Curl() c.setopt(pycurl.URL, 'http://list.mp3.baidu.com/topso/mp3topsong.html?id=1?top2') import StringIO b = StringIO.StringIO() c.setopt(pycurl.WRITEFUNCTION, b.write) c.setopt(pycurl.FOLLOWLOCATION, 1) c.setopt(pycurl.MAXREDIRS, 5) #c.setopt(pycurl.PROXY, 'http://11.11.11.11:8080') #c.setopt(pycurl.PROXYUSERPWD, 'aaa:aaa') c.perform() self.feed(b.getvalue()) 使用 py #!python
# -*- coding: UTF8 -*- ''' 新添加入 top 當天全量 沒有 歌手名 退出 top drop table baidu_Top ; create table baidu_Top ( id integer auto_increment PRIMARY KEY , actor varchar(300) , music varchar(300) , createTime DATE ); ''' import sqlite3,os,sys import datetime, calendar import pdb from baiduTop500 import BaiduTop_GMLParser class Action(): def __init__(self,conn,data): self.conn = conn self.data = data self.allData = [] self.newData = [] self.newNotActorData=[] self.allNotActorData=[] def insertAll(self): insertSql = "insert into baidu_Top (actor,music,createTime) values (?,?,date()) ;" isSql = "select music from baidu_Top where actor=? and music=? and createTime=strftime('%Y-%m-%d',?) ;" isSql2 = "select music from baidu_Top where actor=? and music=? and createTime=strftime('%Y-%m-%d',?) ;" cur = self.conn.cursor() for actor,music in self.data : try : cur.execute(isSql,(actor,music,datetime.date.today()) ) res = cur.fetchall() if not res : cur.execute(insertSql,(actor,music) ) self.allData.append( (actor,music) ) if actor=="" or actor==" " : self.allNotActorData.append((actor,music)) conn.commit() todate=(datetime.date.today()-datetime.timedelta(days=1)) cur.execute(isSql2,(actor,music,todate) ) if not cur.fetchall() : self.newData.append( (actor,music) ) if actor=="" or actor==" " : self.newNotActorData.append((actor,music)) conn.commit() except Exception, myError: excType, excValue, traceBack = sys.exc_info() print excType print myError try : cur.close() except: pass def pfor(title,data): for a,m in data : print "%s\t%s\t%s" %(title,a,m) def line(): print "___________________________________________________________________________________" print "___________________________________________________________________________________" if __name__ == "__main__": try: conn = sqlite3.connect("/home/xj_liukaiyi/src/python/baidu_top/ex500") ac = Action(conn,BaiduTop_GMLParser().getData()) ac.insertAll() #ac.insertNewByDate() print '''說明 %s : new 對比前一天新添加 new not actor 對比前一天新增加但沒歌手名 all 當天top 500 展現全部 all not actor 當天 top 500 展現全部全但沒歌手 ''' %(datetime.date.today()) line() pfor("new",ac.newData) line() pfor("new not actor",ac.newNotActorData) line() pfor("all",ac.allData) line() pfor("all not actor",ac.allNotActorData) finally: conn.close() 再通過系統 crontab -e 郵箱 gbk 轉碼 ,后發送 。每天早上 5點 0 5 * * * /usr/local/bin/python /home/xj_liukaiyi/src/python/baidu_top/Action.py|perl -MEncode -ne 'print encode("GBK", decode("UTF-8",$_));' > tmp ; mail -s "baidu Top 500" liukaiyi@gmail.com < tmp; 我這里有個比較特殊的需求 是要有個 文件夾 能創建,刪除,移動 子文件夾 但 本身文件夾 是不能 刪除的 比如 /tmp/a/b #不能 刪除 /tmp/a/b/c # 能 創建,刪除,移動 這謝謝 perl msn群中的 W.W 幫我解決 具體來說,目錄也是一個文件,但是這個文件的內容,是它的子目錄的結構。對于/tmp/a來說,它是一個文件,但是如果用戶對/tmp/a沒有寫權限,它就改動不了/tmp/a的目錄結構 在/tmp/a里新建目錄,刪除原有的目錄/tmp/a/b,等等,實際改動的是/tmp/a的目錄結構,也就是說,實際改動的是/tmp/a的內容 root: #mkdir /tmp/a; mkdir /tmp/a/b; #chmod a+w /tmp/a/b; chmod o-w /tmp/a user-a: $rmdir /tmp/a/b #This will fail, user-a don't have enough permission. $cd /tmp/a/b; mkdir c; touch d; $rmdir /tmp/a/b/c; rm /tmp/a/b/d; #This is OK. ls -l 中 /tmp/a drwxr-xr-x /tmp/a/b drwxrwxrwx b 文件夾,也就是我上面 需要的文件夾 ,是 777 了但 user-a 是不能刪除的
由于 需求原因,需要匹配 提取中文,大量google下,并沒有我需要的。花了一個小時大概測試,此utf8中文通過,特留文。
參考: http://hi.baidu.com/nivrrex/blog/item/e6ccaf511d0926888d543071.html http://topic.csdn.net/u/20070404/15/b011aa83-f9b7-43b3-bbff-bfe4f653df03.html 首先,確保所有編碼都為 unicode 比如 str.decode('utf8') #從utf8文本中 u"啊l" #在控制臺輸出中 (羅嗦下)本想使用參考一定編碼 Hex 但郁悶的是 這每個字好像占2個位置,使用正則匹配無果。 其次,確定中文范圍 : [\u4e00-\u9fa5] (這里注意下 python 的re寫的時候) 要 u"[\u4e00-\u9fa5]" #確定正則表達式也是 unicode 的 demo : >>> print re.match(ur"[\u4e00-\u9fa5]+","啊")
None >>> print re.match(ur"[\u4e00-\u9fa5]+",u"啊") <_sre.SRE_Match object at 0x2a98981308> >>> print re.match(ur"[\u4e00-\u9fa5]+",u"t") None >>> print tt 現在才明白 >>> tt '\xe7\x8e\xb0\xe5\x9c\xa8\xe6\x89\x8d\xe6\x98\x8e\xe7\x99\xbd' >>> print re.match(r"[\u4e00-\u9fa5]",tt.decode('utf8')) None >>> print re.match(ur"[\u4e00-\u9fa5]",tt.decode('utf8')) <_sre.SRE_Match object at 0x2a955d9c60> >>> print re.match(ur".*["u4e00-"u9fa5]+",u"hi,匹配到了") <_sre.SRE_Match object at 0x2a955d9c60> >>> print re.match(ur".*["u4e00-"u9fa5]+",u"hi,no no") None 其他 擴充 范圍 (轉) 這里是幾個主要非英文語系字符范圍(google上找到的):
2E80~33FFh:中日韓符號區。收容康熙字典部首、中日韓輔助部首、注音符號、日本假名、韓文音符,中日韓的符號、標點、帶圈或帶括符文數字、月份,以及日本的假名組合、單位、年號、月份、日期、時間等。 3400~4DFFh:中日韓認同表意文字擴充A區,總計收容6,582個中日韓漢字。 4E00~9FFFh:中日韓認同表意文字區,總計收容20,902個中日韓漢字。 A000~A4FFh:彝族文字區,收容中國南方彝族文字和字根。 AC00~D7FFh:韓文拼音組合字區,收容以韓文音符拼成的文字。 F900~FAFFh:中日韓兼容表意文字區,總計收容302個中日韓漢字。 FB00~FFFDh:文字表現形式區,收容組合拉丁文字、希伯來文、阿拉伯文、中日韓直式標點、小符號、半角符號、全角符號等。 比如需要匹配所有中日韓非符號字符,那么正則表達式應該是^[\u3400-\u9FFF]+$ 理論上沒錯, 可是我到msn.co.ko隨便復制了個韓文下來, 發現根本不對, 詭異 再到msn.co.jp復制了個’お’, 也不得行.. 然后把范圍擴大到^[\u2E80-\u9FFF]+$, 這樣倒是都通過了, 這個應該就是匹配中日韓文字的正則表達式了, 包括我們臺灣省還在盲目使用的繁體中文 而關于中文的正則表達式, 應該是^[\u4E00-\u9FFF]+$, 和論壇里常被人提起的^[\u4E00-\u9FA5]+$很接近 需要注意的是論壇里說的^[\u4E00-\u9FA5]+$這是專門用于匹配簡體中文的正則表達式, 實際上繁體字也在里面, 我用測試器測試了下’中華人民共和國’, 也通過了, 當然, ^[\u4E00-\u9FFF]+$也是一樣的結果。 轉:http://www.cnblogs.com/yisohoo/articles/1423940.html 我這使用 cu 論壇 下的 rhel-5.1-server-i386-dvd.iso 安裝配置 以前用fedora配置yum很方便,可是來到RHLE就不是那么順手了,如果不做如下設置,經常出現不能通過yum安裝軟件的情況,下面是詳細配置(網上找的)
首先,rhel5系統安裝的時候其實已經有yum了,只是因為如果用官方的網站更新的話除非你是用錢買的rhel5.否則它會提示注冊之類的。所以只要把
yum的更新地址改成開源的就行了。而限定yum更新地址的文件在/etc/yum.repos.d/里。先把它們改成備份文件,即在后面加.bak。
下面有2種方法: 這種我嘗試過,在服務器上已搭建好 yum 參考 : http://www.linuxdiyf.com/viewarticle.php?id=70630 這里注意 vi /etc/yum.conf 和 CentOS-Base.repo 文件中的 5.0 都修改為 5.2 就可以了
方法2 :
#我這安裝地址 如果不行請使用: rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 謝謝 三樓,我這有時間 核實下 告訴大家 。 這樣基本上yum就可以用了。不過如果覺得不爽的話還可以優化:
1. 去除 空行 sed 'N;s/"n/ /g' file 實際問題 主要在編碼問題下。 我把這解決的辦法說下吧,主要這統一 編碼 utf8 0. 數據庫 導入 utf8 如果 導入文本 gbk perl -MEncode -ne 'print encode("UTF-8", decode("GBK",$_));' file.txt > xx.data 1. 代碼編碼 # -*- coding:UTF8 -*- 2. 文件讀取 編碼 cc=bm(x.readline()).split('"t') bm=lambda str : str.decode('gbk').encode('utf-8') 3. 對外輸出 str="%s%s"t" % (str,bmug(f)) bmug=lambda str : unicode(str).encode("utf8") 就是統一編碼 ,我這統一 utf8 # -*- coding: UTF8 -*-
import sqlite3,os """ drop table imusic ; create table imusic( musicname varchar(300) , productid varchar(300) , downcount varchar(300) , musicname2 varchar(300) , actorname2 varchar(300) , iszl varchar(300) , isqu varchar(300) , zlmmf varchar(300) , zlmp3 varchar(300) , qump3 varchar(300) , cpid varchar(300) , cpname varchar(300) , rows varchar(300) , tmp1 varchar(300) ); 如果要使用主鍵 在建表第一列加 id integer auto_increment PRIMARY KEY 文本就要先處理下來 awk 'BEGIN{vi=0}{vi++;print vi"\t"$0;}' 03.data > 03.id.data # 文本 "t 分割 導入 .separator "\t" .import db2.data imusic .separator "," #導出 sqlite> .output a.txt sqlite> select * from tab_xx; sqlite> .output stdout """ conn = sqlite3.connect("ex1") cur = conn.cursor() #編碼轉換 (我這 在 windows 下) bm=lambda str : str.decode('gbk').encode('utf-8') bmcc=lambda str : str.decode('utf8').encode('gbk') bmug=lambda str : unicode(str).encode("utf8") def getValues(actor,music,zlxz,qqxz): try: sql=" select * from imusic where musicname2=? and actorname2=? " cur.execute(sql,( music,actor) ) res = cur.fetchall() if res : data=[] for tt in res[0]: data.append(tt) data[7]='' print zlxz,"*",qqxz if data[8]=='' and data[9]=='' : return None if zlxz=='有振鈴下載' : data[8]='' if qqxz=='有全曲下載' : data[9]='' if data[8]=='' and data[9]=='' : return None return data except Exception, myError: print "[error] %s %s %s %s" % (actor,music,zlxz,qqxz) x = open( "all_comm.txt", "r") cc=x.readline().split('\t') while cc : try: cc=bm(x.readline()).split('\t') dd=getValues(cc[6],cc[5],cc[21],cc[18]) if dd : str = "" for f in dd : str="%s%s\t" % (str,bmug(f)) print str except Exception, myError: print "[error] %s" % cc 下面 demo 注重 update 對比 # conn.total_changes 使用 為 update 跟新 # -*- coding: UTF8 -*-
import sqlite3,os,sys conn = sqlite3.connect("ex4") cur = conn.cursor() #編碼轉換 (我這 在 windows 下) bm=lambda str : str.decode('gbk').encode('utf-8') bmcc=lambda str : str.decode('utf8').encode('gbk') bmug=lambda str : unicode(str).encode("utf8") def getValues(actor,music,zlxz,qqxz,updateRow): try: updateSql = " update imusic set tmp1=? where musicname2=? and actorname2=? " # 1 有振鈴 有全曲 # 2 無振鈴 有全曲 # 3 有振鈴 無全曲 # 4 無振鈴 無全曲 start = "0" ; if zlxz=='有振鈴下載' and qqxz=='有全曲下載' : start="1" if zlxz=='無振鈴下載' and qqxz=='有全曲下載' : start="2" if zlxz=='有振鈴下載' and qqxz=='無全曲下載' : start="3" if zlxz=='無振鈴下載' and qqxz=='無全曲下載' : start="4" cur.execute(updateSql,(start,music,actor) ) if not conn.total_changes==updateRow: updateRow=conn.total_changes log = "[success=%s update=%s] %s-%s:%s %s" % (start,conn.total_changes,actor,music,zlxz,qqxz) else : log = "[giveUp start=%s] %s-%s:%s %s" % (start,actor,music,zlxz,qqxz) print bmcc(log) os.system(" echo %s >> log " % (bmcc(log)) ) conn.commit() return updateRow except Exception, myError: excType, excValue, traceBack = sys.exc_info() print excType print myError x = open( "all_comm2.txt", "r") cc=x.readline().split('\t') myrows=0 updateRow = 0 ; while cc : myrows=myrows+1 try: print "rows = %s " % (myrows) cc=bm(x.readline()).split('\t') updateRow=getValues(cc[6],cc[5],cc[21],cc[18],updateRow) except Exception, myError: excType, excValue, traceBack = sys.exc_info() print excType print myError rsync -avzP cpByDataFile.py --progress xj_liukaiyi@122.102.*.*:/home/xj_liukaiyi/test/ rsync -avzP xj_wanghongbao@10.25.*.*:/newdata2/003.tar.gz --progress . 不需要輸入密碼 在服務器上: su -c 'vim /etc/rsyncd.conf' [gz] path=/home/xj_liukaiyi/gz/ hosts allow = 124.207.100..... read only = no rsync -avzP --password-file=g:\cygwin\secret xj_liukaiyi@122.102.4.90::gz --progress . g:\cygwin\secret 寫入 xj_liukaiyi=123456 |