2010年5月9日 星期日

使用Finder打開隱藏資料夾

我想大家一定都曾遇到這個問題,
就是Finder會自動隱藏 .開頭的檔案,
所以假設我想要安裝新的VIM外掛,
是不是就只能打iterm,用mv指令將檔移過去了。
其實網路上有教學可以把所有的隱藏檔通通顯示出來,
但是還是要輸入指令才能開啟這樣功能,實在是太不人性化。

其實,山不轉路轉,要開啟隱藏資料夾並沒有這麼困難,
假設我要打開VIM的設定資料夾 ~/.vim,
只要打開Finder,選擇“前往” > “前往資料夾”,
如下圖所示:
螢幕快照 2010-05-09 下午3.17.54.png


再輸入~/.vim,

螢幕快照 2010-05-09 下午3.33.55.png


這樣神祕的隱藏檔就開起來啦。
如此一來不用使用mv也能將外掛移到~/.vim底下。

用Mac一年多了才知道可以這樣用,
消息實在是太不靈通啦。

2010年5月2日 星期日

在Mac osx 10.6.3(Snow leopard)中灌TinyOS2.x

好久沒寫有關TinyOS的文章了,最近又要開始動手改code了,
看來不在自己的MBA上灌TinysOS不行啦,
近期之內,應該會寫幾篇有關TinyOS的文章,
也算是對TinyOS社群有所貢獻。
所以廢話不多說,在Mac osx 10.6.3灌TinyOS2.x的安裝步驟如下:

Step 1 安裝之前需要的工具



我的安裝環境是OSX 10.6.3,現在要安裝TinyOS已經變的很簡單了,
只要先行安裝必要的工具,就可以無痛安裝,需要的工具如下:

1. Xcode
由於我本身就已經安裝了Xcode ,所以我不確定如果沒有Xcode,會不會在安裝的過程中出現問題。
下載位置:
http://developer.apple.com/tools/xcode/

2.MacPorts
因為已經有熱心的朋友將TinyOS所需要的軟體發佈在Ports上,所以只要安裝MacPorts,
一些TinyOS必要的軟體像是NesC、AVR GCC,就不用自己手動去抓下來安裝了。
下載位置:
http://www.macports.org/
3.Git
Git為版本控制軟體,因為我希望能下載到TinyOS的程式,
所以需要透過版本控制軟體來下載,其實用CVS也可以下載最新的code回來,
但是,我發現用Git速度快上好幾倍,所以,當然要用Git啦。
您可以使用port安裝Git,不過我自己是到google code上抓git的installer,因為我有搜集dmg的習慣。
下載位置:
http://code.google.com/p/git-osx-installer/

Step 2 安裝NesC、 AVR GCC compiler 和MSP GCC



安裝完基本的工具之後,現在我們要正式開始安裝TinyOS了,
首先,我們必須修改並新增一個Port的來源,並且增修port的設定,方法如下:

cd /Users/user 
git clone git://hinrg.cs.jhu.edu/git/ports.git

到你的家目錄底下,用Git下載Razvan包好的port來源。

接著修改macports的sources.conf,在裡面加入剛才下載回來的檔案位置:
sudo vi /opt/local/etc/macports/sources.conf

加入
#在rsync之前加入以下這行,記得一定要放在rsync之前,不然會發生錯誤,如下所示
file:///Users/hdj/ports
rsync://rsync.macports.org/release/ports/ [default]


設定完port之後,我們可以開始安裝NesC和avr/msp430 tools

sudo port install msp430-binutils-tinyos msp430-gcc-tinyos msp430-libc-tinyos (for MSP430)
sudo port install avr-binutils-tinyos avr-gcc-tinyos avr-libc-tinyos avrdude-tinyos (for AVR)
sudo port install nesc


Step 3 下載TinyOS source code並且安裝相關的程式



這裡我們到家目錄,用Git將最新版的TinyOS下載回來:
cd /Users/user
git clone git://hinrg.cs.jhu.edu/git/tinyos-2.x.git


下載回來之後,我們必需要設定一些環境變數,才能讓TinyOS正確的運行,
這裡通常是最難搞的地方,因為只要有環境變數設定錯誤,TinyOS就無法正常編譯成功。
還好TinyOS官方有提供一個環境設定檔tinyos.sh,但是我覺得並不好用,還是有一些參數沒有設定完整,所以,參考了我之前下載的script,改了一份新的設定檔,加入了一些常用的指令和java的設定,大家可以參考看看。
請記得修改.bashrc,並加入
source ~/Documents/tinyos/tinyos.sh
其中,~/Documents/tinyos/是你下載tinyos.sh的存放位置。

接著將TinyOS的一些Tool安裝起來:
cd $TOSROOT/tools
./Bootstrap
./configure
make
sudo make install 
sudo tos-install-jni 


安裝完所有的tool之後,可以輸入以下指令確認是否有TinyOS的工具可以使用:
motelist

或者也可以檢查一下有沒有什麼設定或是軟體還沒安裝:
tos-check-env


原則上,到這一步,如果環境設定都沒有問題的話,就算是安裝完成了,
有任何的問題,一定是環境設定沒有設定好,就必須檢查有那一個步驟遺漏掉了。

Step 4 安裝 FTDI Drivers


為了要讓motelist可以正常讀取到Mote的資訊,請下載安裝FTDI driver
下載位置:
http://www.ftdichip.com/Drivers/VCP.htm

Step 5 重編java tool



如果需要不需要重編java tool的朋友,這個步驟可以跳過。

由於官方建議使用gcc44來編繹程式,所以我使用port下載,不過安裝gcc44需要很多時間,好幾個小時吧,我是放給他跑,睡一覺起來才安裝好的,安裝指㐴如下:

sudo port install gcc44
sudo port install gcc_select 

gcc_select是用來切換所需要的gcc,可用gcc_select -l察看主機上有灌了什麼版本的GCC,
如果要切換成gcc44,可輸入以下指令:
gcc_select mp-gcc44 

如果要切回原來的gcc42,指令如下:
gcc_select gcc42 


目前我自己測試是沒有需要用到gcc44,因為我沒有重新編譯TinyOS的java tool,
如果有需要重新編譯java tool的朋友,才會需要使用到gcc44




Step 6 試著編譯應用程式



重頭戲來了,讓我們來編譯一個程式看看:
cd $TOSROOT/apps/Blink
make telosb 


如果沒有error,而且看到以下訊息,就表示TinyOS已經安裝成功:

    compiled BlinkAppC to build/telosb/main.exe
            2648 bytes in ROM
              54 bytes in RAM
msp430-objcopy --output-target=ihex build/telosb/main.exe build/telosb/main.ihex
    writing TOS image


恭喜啦,您可以開始編寫TinyOS的程式了~~


疑難雜症



Problem 1 Compile 含有Java的程式

例如,如果在編譯estSerial過程中,出現了以下的錯誤訊息:

hdj@MBA:~/tinyos-2.x/apps/tests/TestSerial$ make telosb
mkdir -p build/telosb
mig java -target=null -I/Users/hdj/Documents/tinyos/tinyos-2.x/tos/lib/T2Hack -DIDENT_APPNAME=\"TestSerialAppC\" -DIDENT_USERNAME=\"hdj\" -DIDENT_HOSTNAME=\"Huang-Ding-jiet\" -DIDENT_USERHASH=0x8527c6dbL -DIDENT_TIMESTAMP=0x4bfc99feL -DIDENT_UIDHASH=0x69b76063L -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o TestSerialMsg.java
cat: java: No such file or directory
mig: fatal: "java", line 1: no SubSystem declaration
warning: option "-target=null" after filename(s) ignored
warning: option "-I/Users/hdj/Documents/tinyos/tinyos-2.x/tos/lib/T2Hack" after filename(s) ignored
warning: option "-DIDENT_APPNAME="TestSerialAppC"" after filename(s) ignored
warning: option "-DIDENT_USERNAME="hdj"" after filename(s) ignored
warning: option "-DIDENT_HOSTNAME="Huang-Ding-jiet"" after filename(s) ignored
warning: option "-DIDENT_USERHASH=0x8527c6dbL" after filename(s) ignored
warning: option "-DIDENT_TIMESTAMP=0x4bfc99feL" after filename(s) ignored
warning: option "-DIDENT_UIDHASH=0x69b76063L" after filename(s) ignored
warning: option "-java-classname=TestSerialMsg" after filename(s) ignored
/usr/bin/mig: line 207: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/TestSerial.h.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/TestSerial.h.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: no input files
mig: fatal: "<no name yet>", line -1: no SubSystem declaration
/usr/bin/mig: line 207: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/test_serial_msg.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/test_serial_msg.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: no input files
mig: fatal: "<no name yet>", line -1: no SubSystem declaration
warning: option "-o" after filename(s) ignored
/usr/bin/mig: line 207: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/TestSerialMsg.java.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow/TestSerialMsg.java.19983.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: no input files
mig: fatal: "<no name yet>", line -1: no SubSystem declaration
rmdir: /var/folders/5W/5WdvGkinHMGZ7JuCEC53Pk+++TI/-Tmp-//mig.YPmOow: No such file or directory
javac -target 1.4 -source 1.4 *.java
TestSerial.java:45: cannot find symbol
symbol  : class TestSerialMsg
location: class TestSerial
    this.moteIF.registerListener(new TestSerialMsg(), this);
                                     ^
TestSerial.java:50: cannot find symbol
symbol  : class TestSerialMsg
location: class TestSerial
    TestSerialMsg payload = new TestSerialMsg();
    ^
TestSerial.java:50: cannot find symbol
symbol  : class TestSerialMsg
location: class TestSerial
    TestSerialMsg payload = new TestSerialMsg();
                                ^
TestSerial.java:69: cannot find symbol
symbol  : class TestSerialMsg
location: class TestSerial
    TestSerialMsg msg = (TestSerialMsg)message;
    ^
TestSerial.java:69: cannot find symbol
symbol  : class TestSerialMsg
location: class TestSerial
    TestSerialMsg msg = (TestSerialMsg)message;
                         ^
5 errors
make: *** [TestSerial.class] Error 1


這表示你的mig工具設定有問題,請使用以下指令解決:

export PATH=$TOSROOT/tools/tinyos/ncc/:$PATH
chmod  a+x $TOSROOT/tools/tinyos/ncc/mig

這裡主要是因為mig的權限問題,所以,只要讓mig可執行問題就可以解決。

Problem 2

但是,修改完權限之後,在MAC OSX上還會出現另外一個問題,如下所示:

hdj@MBA:~/tinyos-2.x/apps/tests/TestSerial$ make telosb
mkdir -p build/telosb
mig java -target=null -I/Users/hdj/Documents/tinyos/tinyos-2.x/tos/lib/T2Hack -DIDENT_APPNAME=\"TestSerialAppC\" -DIDENT_USERNAME=\"hdj\" -DIDENT_HOSTNAME=\"Huang-Ding-jiet\" -DIDENT_USERHASH=0x8527c6dbL -DIDENT_TIMESTAMP=0x4bfc9a4fL -DIDENT_UIDHASH=0x1795bab5L -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o TestSerialMsg.java
In file included from /usr/include/string.h:148,
                 from /Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/tos.h:13:
/usr/include/secure/_string.h: In function `__inline_memcpy_chk':
/usr/include/secure/_string.h:58: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_memmove_chk':
/usr/include/secure/_string.h:69: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_memset_chk':
/usr/include/secure/_string.h:80: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_strcpy_chk':
/usr/include/secure/_string.h:91: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_stpcpy_chk':
/usr/include/secure/_string.h:103: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_strncpy_chk':
/usr/include/secure/_string.h:116: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_strcat_chk':
/usr/include/secure/_string.h:127: warning: return makes pointer from integer without a cast
/usr/include/secure/_string.h: In function `__inline_strncat_chk':
/usr/include/secure/_string.h:139: warning: return makes pointer from integer without a cast
In file included from /Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/tos.h:14:
/usr/include/stdlib.h: At top level:
/usr/include/stdlib.h:272: syntax error before `^'
/usr/include/stdlib.h:272: `type name' declared as function returning a function
/usr/include/stdlib.h:274: syntax error before `^'
/usr/include/stdlib.h:274: `type name' declared as function returning a function
/usr/include/stdlib.h:301: syntax error before `^'
/usr/include/stdlib.h:301: `type name' declared as function returning a function
/usr/include/stdlib.h:307: syntax error before `^'
/usr/include/stdlib.h:307: `type name' declared as function returning a function
/usr/include/stdlib.h:313: syntax error before `^'
/usr/include/stdlib.h:313: `type name' declared as function returning a function
/usr/include/stdlib.h:319: syntax error before `^'
/usr/include/stdlib.h:319: `type name' declared as function returning a function
In file included from /Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/SchedulerBasicP.nc:41,
                 from /Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/TinySchedulerC.nc:40:
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/platforms/null/hardware.h: In function `__nesc_ntoh_afloat':
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/platforms/null/hardware.h:22: warning: pointer/integer type mismatch in conditional expression
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/platforms/null/hardware.h: In function `__nesc_hton_afloat':
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/platforms/null/hardware.h:27: warning: pointer/integer type mismatch in conditional expression
In file included from /Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/TinySchedulerC.nc:40:
In component `SchedulerBasicP':
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/SchedulerBasicP.nc: In function `Scheduler.init':
/Users/hdj/Documents/tinyos/tinyos-2.x/tos/system/SchedulerBasicP.nc:117: warning: pointer/integer type mismatch in conditional expression
failed to parse message file TestSerial.h
make: *** [TestSerialMsg.java] Error 1


這個問題的解法有兩種:

第一種解法--
這是因為Makefile的問題,請將你的Makefile中,
編譯java欄位裡的target值,從null改為$(PLATFORM),
如下所示:

 mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o $@


這樣就能夠正常compile了。
參考來源:
http://old.nabble.com/Re:-Build-errors-for-TestSerial----resolved-td26123725.html

第二種解法--
剛才我們有提到是Makefile的問題,
但是追根究底,主要還是因為Snow leopard上的gcc42對null語法的解讀錯誤,
所以,如果不想改Makefile,而且在之前Step 5有安裝gcc_select的朋友,
可以使用以下指令,在每次compile java程式之前,先將預設的gcc版本改為gcc44。

sudo gcc_select mp-gcc44 



後話



感覺在ubuntu上安裝TinyOS2比在OSX上安裝方便而且快速,
果然有編譯的執行檔還是比較方便,可惜MAC上還沒有人將TinyOS包成DMG檔,
有空再來研究看看好了。
此外,本篇文件主要是參考這篇文章,如有需要可以前往參考。

參考來源:
http://research-machine.blogspot.com/2010/01/how-to-install-tinyos-2-on-macosx-106.html
http://docs.tinyos.net/index.php/Installing_from_CVS/GIT
http://www.mail-archive.com/tinyos-help@millennium.berkeley.edu/msg31149.html
http://www.mobilab.unina.it/TinyOSMAC.htm

2010年4月9日 星期五

Chrome 也有1password的外掛啦~

原來Chrome也有1password的外掛,其實我已經outdate很久了,
好像1月份就有alpha版了,只是我不常用Chrome。

今天心血來潮用了一下Chrome,真的感覺有比較快一點,
然後不小心發現我的1password好像沒有內建chrome的外掛,
所以只好自己去找看看有沒有人提供,
好在官方有提供,請參考下列教學網址:

http://blog.agile.ws/post/450843073/a-1password-alpha-for-chromium-is-here

懶得看英文的話,直接點以下網址安裝外掛程式:

http://agile.ws/s/a330894b8

安裝完右上角就會多一個1password的icon,在chrome上也可以不用記密碼啦~~哈哈

2010年4月4日 星期日

Hinet 撥接式固定IP mail server relay設定

前陣子我用hinet adsl撥接申請的固定IP,
一直有一個困擾我很久的問題,
那就是寄給Gmail的信,總是不定期的給我退信,
今天總算是讓我找到方法解決了。

原來hinet為了要防止別人任意架mail server 發送垃圾信所以關了relay,
所以,我的IP才會被Gmail列入黑名單中,
要解決的方法不難,
只要修改/etc/postfix/main.cf,在relayhost的欄位中加入

[ms32.hinet.net]:25

指令如下:

$ sudo vi /etc/postfix/main.cf


relayhost = [ms32.hinet.net]:25


然後重新啟動postfix,

$sudo /etc/init.d/postfix restart

這樣信件就可以正常發送到Gmail了。

參考來源:
http://moto.debian.org.tw/viewtopic.php?f=12&t=13545

2010年4月3日 星期六

Mac+iPhone 有感

自從買了MBA+iPhone 3Gs之後,真的感受到了MAC家族帶來的便利和整合性,
尤其是iPhone和Mac OSX的整合性,我可以在我的iPhone上做備忘錄,
然後回家之後再透過USB連線同步我iPhone上的資料。
而且iPhone和Mac上的Mail和iCal又都可以跟Gmail和Google calendar同步,
讓我完全不用擔心系統轉移會造成任何的不便。

在我花了時間學習這些新工具之後,我不禁靜下來思考,
MAC+iPhone的確帶給我便利性,讓我可以隨時隨地察看信件和行事曆,
不過其實我真的會用到iPhone來查信件的時間很少,
可能是因為我的身邊總是有電腦和網路吧,
所以,iPhone上的許多工具,對於我來說已經越來越少在用了,
最常使用的大概就記帳軟體和一些打發時間的小遊戲,

而現在對我而言最常使用的工具則是evernote,
因為evernote可以線上同步筆記和一些記事,
反正用iPhone來記事的時間本來就不是很多了,
大部份都是在電腦上記完事之後再同步到iPhone上看,
所以,還滿推薦大家使用evernote的。

綜合地來看,轉換到MAC之後,其實我最需要的工具還是能線上即時同步的工具,
因為我本身需要同時在不同的平台上工作,所以對於軟體的好壞,跨平台則是我的首要條件。
相信將來任何的系統軟體都必須要有跨平台的能力才會大賣。

Curl 截取ASPX的網頁資訊

最近剛好想要撈一個ASPX網頁的資料,
想說用php+curl就可以輕易的透過post將資料截取回來,
不過,實際去寫code的時候就會發現,其實ASP並沒有這麼容易就可以下載回來。
因為,ASP在post資料時,會將一些訊息紀錄在__VIEWSTAT這個欄位中,
如果沒有取得這個欄位的資料,則用post請求的資料會變的不正確,
因此,若想要取得正確的資料,就必須先下載請求的頁面,並且剖析取出__VIEWSTAT的值,再將__VIEWSTAT的值填入參數之中,一起送出請求,
這樣才能正確的截取資料回來了。

參考來源:

http://www.phpbuilder.com/board/archive/index.php/t-10328567.html

http://my-web-design.blogspot.com/2008/11/curl.html

所以,我們舉個例子,以便說明程式的寫法:

Step1 取得__VIEWSTAT資料

首先跑一次Curl,將__VIEWSTAT的參數內容截取回來:

$link = "http://test.web.idv.tw/query.aspx";
$ch = curl_init($link);
if (!$ch)
{
die( "Cannot allocate a new PHP-CURL handle" );
}
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 13); //times out after 4s
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
$token = "__VIEWSTATE";
$result = strstr($result, $token);
$result = substr($result, strlen($token));
$endpos = strpos($result, \'" />\');
$result = substr($result, 9,$endpos-9);
//URLENCODE
$result= urlencode($result);


其中這段程式的第一行的$link是欲下載目標連結,第7~11行是curl的參數設定,第12行是第一次使用curl下載表單,第13~17行則是將__VIEWSTATE的參數截取回來。第19行則是將取得的資料轉換成url的型態,這樣之後可以直接將$result當做參數,再向同一個網頁要求資訊。

這裡比較要注意的是第17行可能會因為ASP欄位的不同,資料所在也不同,所以要自行修改截取的位置。

Step2 正式要求我們所要的資料

接著我們再次要求我們所需要的資料,假設我們現在要post的資料欄位是日期和IP位置,
那就必須將日期、IP和viewstat的資料結合在一起,然後一次送出,
範例如下:


/**
* For getting date from query
*/
$viewstat = "__VIEWSTAT=$result";
$dodate = "dodate=2014/03/22";
$ip = "ip=211.211.211.211";
$all_arguments= $viewstat.$dodate.$ip ;
//Request data
$link = "http://test.web.idv.tw/query.aspx";
$ch = curl_init($link);
if (!$ch)
{
die( "Cannot allocate a new PHP-CURL handle" );
}
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 13); //times out after 4s
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$all_arguments);
$data=curl_exec($ch);


其中第1~4行是在整理參數,第6行之後是重新在要一次資料,這次我們將取得的資料存放在$data中。
按照這樣的步驟,就可以正常取得ASPX的資料了


2010年3月17日 星期三

iPhone 3Gs 簡訊備份法

之前看過有些軟體可以讓你在電腦上看到簡訊內容,
甚至是將簡訊備份下來,
但是這些軟體大部份都是需要收費的。
這些軟體有他的方便之處,功能也相當的強大,但是我單純只是想要備份我自己iPhone上的簡訊內容,
不知道有沒有其它直接的方法可以直接存取簡訊的內容呢?

其實真的可以直接取得簡訊的內容,而不需要特別額外的軟體,
因為在使用iTune和iPhone同步的時候,
iTune會自動幫使用者將所有iPhone上的內容備份下來,
所以只要找到相對應的儲存位置,
就可以將我們想要備份的資料另存下來。
因此,只要按照以下步驟就可以手動備份自己的簡訊啦~~

Step1 簡訊存放位置

說穿了,只要知道簡訊資料庫存放在哪裡,
一切都會變得很簡單。
而一般個人的簡訊會存放在
~/Library/Application Support/MobileSync/Backup/{some long string of hexadecimal characters}/
的3d0d7e5fb2ce288813306e4d4636395e047a3d28.mddata

其實這個檔案原本是sqlite檔,所以我們先將這個檔案另存一份,並且把他改名為sms.sqlite,
記住不要自行修改這個檔案,不然會導致手機上的簡訊異常。
所以,我是將這個檔案複製一份,並且放在桌面上處裡。

Step2 用Sqlite開啟檔案

原則上用任何的Sqlite工具應該都可以開啟這個sms.sqlite,
只是這裡我用Firefox的外掛sqlite manager開起這個資料庫檔案,
因為不用下載其它特別的軟體,用firefox就可以打開了。
sqlite manager可以到Firefox的add-on下載:

螢幕快照 2010-03-05 上午10.44.30.png


所以,使用Sqlite manager開啟sms.sqlite,
如下圖所示:

螢幕快照 2010-03-05 上午1.53.16.png


從這張圖中,我們點選左上角的message,就可以看到所有簡訊,

接著依下圖所示選取滙出的選項:
螢幕快照 2010-03-17 下午6.49.04.jpg


並且另存成message.csv檔:

螢幕快照 2010-03-17 下午6.50.59.png


這樣就大功告成啦,以後我們就可以使用number或是excel開啟message.csv檔了,
iphone上的簡訊就這麼容易地備份下來啦~~
雖然無法直接知道簡訊是誰傳來的,但是簡訊內容的前個欄位有手機號碼,
相信要自行修改也不是什麼難事。
其實應該也是可以自已寫個小程式將簡訊轉換一下,
有空再說吧~~


參考來源:

http://www.play01.com/topicdetail.php?f=383&t=1330923

Related Posts Plugin for WordPress, Blogger...