2012年5月23日 星期三

Linux環境下 console模式下抓封包



我的使用方式,開兩個terminals,一個執行
$ tcpdump -i eth0 -w abc.cap

另一個執行
$ tcpdump -r abc.cap 

使用tcpdump指令3個會用到的options


Ex.抓封包存入abc.cap檔案
$ tcpdump -i eth0 -w abc.cap 

Ex. 抓封包,分割每個儲存的封包(size 1500bytes)
$ tcpdump -i eth0 -s 1500 -w a.cap 

Ex. 讀封包
$ tcpdump -r abc.cap 

p.s. 必須使用root權限

2012年5月22日 星期二

[SOAP] No address associated with

PHP SOAP在Load wsdl時發生的錯誤
Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: No address associated with 
相關討論串Non-SOAP bindingBug#50443

解決方法為移除無Address的port之Binding,如下紅色部分。

Example:


  
    https://services.contentdirect.tv/v3.0/SubscriberService.svc"/>
  
  



2012年5月18日 星期五

VAIO 顯卡更新成官網最新driver方法

最近想要把我的VAIO sz58的顯示卡驅動程式更新到最新時,發現nVidia官方driver無法安裝,所以google了一下解決方法



依照以下步驟:
1. 下載對應到官方網站最新nVidia驅動程式版本,先執行一次,他會把安裝軟體解壓縮到C槽。
2. 到下面路徑找到兩個檔案 nvaa.inf, nvac.inf (版本號296.10會不一定會一樣)

C:\NVIDIA\DisplayDriver\296.10\WinVista_Win7\International\Display.Driver\

3. 修改裡面的內容 (記得先備份),每個檔案有3個sections要改,有兩個是緊接著[Manufacturer]這個section之後的兩個sections,另一個是[Strings]這個section,要加的內容都加在所屬section的最後面。 (紅色字體為要加的內容)

另外特別注意的是"PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D" 此為你的顯卡硬體裝置ID,可在Device manager裡查看,如下圖



nvaa.inf
...

[Manufacturer]
%NVIDIA_A% = NVIDIA_SetA_Devices,NTx86.6.0,NTx86.6.1

[NVIDIA_SetA_Devices.NTx86.6.0]

%NVIDIA_DEV.0407.0770.152D% = Section001, PCI\VEN_10DE&DEV_0407&SUBSYS_0770152D 
%NVIDIA_DEV.0407.1515.1043% = Section001, PCI\VEN_10DE&DEV_0407&SUBSYS_15151043 
...
%NVIDIA_DEV.0427.01% = Section001, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D


[NVIDIA_SetA_Devices.NTx86.6.1]
%NVIDIA_DEV.0407.0770.152D% = Section002, PCI\VEN_10DE&DEV_0407&SUBSYS_0770152D 
%NVIDIA_DEV.0407.1515.1043% = Section002, PCI\VEN_10DE&DEV_0407&SUBSYS_15151043 
...
%NVIDIA_DEV.0427.01% = Section002, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D


[Strings]
DiskID1 = "NVIDIA Windows Vista / Windows 7 (32 bit) Driver Library Installation Disk 1"
NVIDIA = "NVIDIA"
NVIDIA_A = "NVIDIA"
NVIDIA_DEV.0407.0770.152D = "NVIDIA GeForce 8600M GT"
NVIDIA_DEV.0407.1515.1043 = "NVIDIA GeForce 8600M GT "
...
NVIDIA_DEV.0427.01 = "NVIDIA GeForce 8400M GS"

nvac.inf
...


[Manufacturer]
%NVIDIA_A% = NVIDIA_SetA_Devices,NTx86.6.0,NTx86.6.1

[NVIDIA_SetA_Devices.NTx86.6.0]
%NVIDIA_DEV.0405.011D.1025% = Section001, PCI\VEN_10DE&DEV_0405&SUBSYS_011D1025 
%NVIDIA_DEV.0405.011E.1025% = Section001, PCI\VEN_10DE&DEV_0405&SUBSYS_011E1025 
...
%NVIDIA_DEV.0427.01% = Section001, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D

[NVIDIA_SetA_Devices.NTx86.6.1]
%NVIDIA_DEV.0405.011D.1025% = Section002, PCI\VEN_10DE&DEV_0405&SUBSYS_011D1025 
%NVIDIA_DEV.0405.011E.1025% = Section002, PCI\VEN_10DE&DEV_0405&SUBSYS_011E1025 
...
%NVIDIA_DEV.0427.01% = Section002, PCI\VEN_10DE&DEV_0427&SUBSYS_9008104D

[Strings]
DiskID1 = "NVIDIA Windows Vista / Windows 7 (32 bit) Driver Library Installation Disk 1"
NVIDIA = "NVIDIA"
NVIDIA_A = "NVIDIA"
NVIDIA_DEV.0405.011D.1025 = "NVIDIA GeForce 9500M GS"
NVIDIA_DEV.0405.011E.1025 = "NVIDIA GeForce 9500M GS "
...
NVIDIA_DEV.0427.01 = "NVIDIA GeForce 8400M GS"

4. 修改完後,存檔,重新執行setup.exe,此執行檔會在下面這個目錄
C:\NVIDIA\DisplayDriver\296.10\WinVista_Win7\International
5. 重開機

Done

2012年4月6日 星期五

PHP SOAP (WSDL)

最近在接觸WSDL時,碰到了一些NameSpace設定上的問題,在此memo設定方式。

WSDL file的一段

< element name='funcA' >
  < complexType >
    < sequence >
      < element name='param1' type='abc:elementA' >
      < element name='param2' type='abc:elementB' >
    < /sequence >
  < /complexType >
< /element >

< complexType name=' elementA' >
  < sequence >
    < element name='AA' type='xsd:string'>
  < /sequence > 
< /complexType >

< complexType name=' elementB' >
  < sequence >
    < element name='abc:elementBB' type='abc:BB' >
  < /sequence > 
< /complexType >

< complexType name=' elementBB' >
  < sequence >
    < element name='BBB' type='xsd:int' >
  < /sequence > 
< /complexType >

如上為一段WSDL中一段function call內容的定義,funcA有一個Complex Type的 input 參數,包著一個 sequence,裡面有兩個elements。此兩個 elements皆為自定義 variable。必須指定其所給的NameSpace (abc)。

所以就會成為以下設定
$params = array('param1'=>new SoapVar(array("AA"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc'), 'param2'=>new SoapVar(array( "elementBB"=>new SoapVar(array("BBB"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementBB', 'abc') ), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc'));

首先,先分開來看,先看怎麼定義第一個element 'param1'
new SoapVar(array("AA"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc')

再來是第二個element 'param2'
new SoapVar(array( "elementBB"=>new SoapVar(array("BBB"=>'test'), SOAP_ENC_OBJECT, null, null, 'elementBB', 'abc') ), SOAP_ENC_OBJECT, null, null, 'elementA', 'abc')

上面黃色部分是BB底下又包了一層complex type 'elementBBB',先不看這部分的話 其實是跟 'param1'是一樣的

最後把上面兩個elements用Array合起來,並給予name index,即完成!

如果有name沒設,或NameSpace沒設,有些server會認不出來而產生error。


2012年3月15日 星期四

Linux ~/.vimrc 設定

原文網址

在 Terminal中輸入
gvim ~/.vimrc
可設定以下內容 (以下是我個人的設定)

syntax on                           " 語法上色顯示
set ai              "自動縮排
set tabstop=2        " 設定縮排寬度 = 2
set softtabstop=2    " tab 的字元數
set shiftwidth=2           
set ruler            " 顯示右下角設定值
set ic               " 設定搜尋忽略大小寫
set ru               " 第幾行第幾個字
set hlsearc          " 設定高亮度顯示搜尋結果
set incsearch        " 在關鍵字還沒完全輸入完畢前就顯示結果
set smartindent
set history=100      " 保留 100 個使用過的指令

set nocp



colorscheme torte 

2012年3月14日 星期三

Linux File Time (atime, ctime, mtime)

st_atime
           Time when file data was last accessed. Changed by  the
           following   functions:   creat(),   mknod(),   pipe(),
           utime(2), and read(2).

st_mtime
           Time when data was last modified. Changed by the  fol-
           lowing  functions:  creat(), mknod(), pipe(), utime(),
           and write(2).

st_ctime
           Time when file status was last changed. Changed by the
           following   functions:   chmod(),   chown(),  creat(),
           link(2),  mknod(),  pipe(),  unlink(2),  utime(),  and
           write().


指令可使用
stat -c %x filename
stat -c %y filename
stat -c %z filename
或者
ls -lu  filename
ls -l    filename
ls -lc  filename


-lu    show access time and sort by name
-l     show modified time and sort by name
-lc   show ctime and sort by name

%x   Time of last access
%y   Time of last modification
%z   Time of last change

2012年3月12日 星期一

簡易 Linux FTP upload shell

簡易的FTP 檔案上傳Shell script


於Terminal中,輸入
gvim ftpUpload.sh
並輸入下列內容於此檔案
#!/bin/bash
echo file(s) upload $*;
ftp -v -i -n FTP位址 << FTPIT
user 帳戶 密碼
bin
cd /切換至要放上傳檔案的目錄
mput $*
quit
FTPIT
exit 0
存檔離開,並改變此檔案的屬性
chmod 755 ftpUpload.sh
最後,執行
./ftpUpload.sh file1.txt file2.doc file3.mov

p.s. 後面帶的參數即為要傳送的檔案名,而$*則為儲存所有arg的變數(以空格區隔)

Gvim plugin安裝於Ubuntu



以下內容出自上面原文,我再加上修改後,可於Ubuntu上安裝成功

註解程式快捷鍵plugin

於Terminal中輸入下列指令
sudo apt-get install vim-addon-manager vim-scripts
vim-addons install enhanced-commentify
即可
於Gvim中,將游標移至想要註解的那一行後按下
\+x
若要往下一行繼續註解,則按下
\+c

2012年3月6日 星期二

Ubuntu Wifi Hotspot不斷連線 斷線

在Ubuntu 11.10的版本,建立Hotspot後會不停的斷線與連線問題,嘗試了很多解法後,下面方法可以workable !
原文連結--> Cannot make Wi-Fi hotspot

1. go to System settings > Network > Wireless > Use as hotspot > Configure (or 'Edit connections' under your connections > Edit the hotspot connection)
2. Switch to IPv6 Settings tab > Set Method to 'Ignore' and confirm/save
3. in terminal (Ctrl + Alt + T) run the following command to kill all dnsmasq processes: sudo killall dnsmasq
4. go to System settings > Network > Wireless > Use as hotspot

搜尋此網誌