搜尋此網誌

2009/07/20

筆記:在Cygwin上能顯示中文的xterm

遠端的系統大多已經有中文環境,但是傳統的xterm並不能正確的顯示中文,在此以Fedora 11為例,記錄如何能讓Fedora 11遠端的xterm能顯示中文


其實xterm並不能正確的顯示中文,在網路上有找到rxvt這個工具,它可以顯示中文。在Fedora中,安裝以下套件:
rxvt
rxvt-unicode
這二個是有機會可顯示中文的,以目前我自己的設定上來說,Fedora其環境是Unicode
顯示中文的方式,如在之前已經用xterm連線成功的話,輸入ls -l中文目錄會出現亂碼。而換了使用rxvt後,結果也一樣,但是如果用urxvt (unocide版)的話,中文就能正常顯示了。

在urxvt中,要複製選取字元,用Ctrl-Insert,貼上用Shift-Insert。

筆記:Cygwin上安裝XWindow 環境

Cygwin是一套跑在Windows平台上,模仿Unix環境的系統,完全免費,也方便和Unix環境連結。其X11環境是我最常用的。


安裝:
確定在Cygwin安裝時,要有安裝X11選項(內定是不裝,要改成"install"),另外Net中的openssh及inetutils要裝。X11項目中,要檢查xinit,xorg-server,xorg-docs,X-start-menu-icons(非必要)有裝。
輸入startxwin.bat啟動X11環境,在啟動的X11視窗中,輸入:

xhost + <允許連過來的IP>

比如:
$ xhost + 192.168.0.18
192.168.0.18 being added to access control list

接著ssh到Linux主機(即要將顯示丟過來的主機):
ssh -Y -l username remote_hostname_or_ip_address

比如:
ssh -Y -l user1 192.168.0.18

確定xterm在Linux上有安裝後,在ssh的那個連線階段,輸入 「xterm &」,遠端的連線就會全導到PC上了。

筆記:Cygwin上可顯示中文的技巧

修改 ~/.inputrc (用vi或是vim),加入以下幾行:
set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

修改 ~/.bash_profile,要有以下幾行:
export LESSCHARSET=latin1
alias less='/bin/less -r'
alias ls='/bin/ls -F --color=tty --show-control-chars'

2009/07/13

QNAP TS-409 iTune Service troubleshooting.
Well, I got some problem with TS-409 iTunes service, so I decide to fix it.....for whole day.
You must have a little Unix skills if you want to try to fix it.


So, I enjoy my TS-409 with iTunes server, it makes me easy to listen to my favorite music.
Well, on February I bought a new mobile phone, it supports MP3 play. But it only support UNICODE ID3 tags. So I decide to convert all my MP3 existing tags from BIG5 to UNICODE. Then My TS-409 iTunes service stop working.
Yesterday, I upgraded firmware to 3.1, it still not working....So I decide to figure out why it stop working.

First I SSH to TS-409, and type following command:

ps -ef|grep daapd

mt-daapd is iTunes service process name, usually system will spam around 5 processes for iTunes. I found there is no daapd process running. So I restart iTunes service from admin interface. This time I found daapd consumes all CPU resources (via command top)

So, there should be a problem in daapd. Maybe it hang in one of these MP3 files? If I moved all MP3 files out, the service is back. But it's hard to figure out which MP3 cause this problem.

The next 2 hours I waste my time in move MP3 files out and in. Finally I give up.

so I decide to find which MP3 cause daemon hang? I SSH to TS-409 and type:

ps -ef|grep daapd

System reported there is 5 processes running now. Next, use top command to find which pid that consumes CPU. Write down the pid. In this example, if the pid is 9181, issue this command:

cd /proc/9181/fd

Change directory to /proc//fd
This directory displayed opening files for the pid. Enter this command:

ls -l

Very simple, list which MP3 cause daemon hang. Please note: set SSH client character encoding to UTF-8. Or the screen display may be incorrect. Next, find out the MP3 file, fix it's ID3 tag. Repeat these steps, finally my iTunes service is back.