Wednesday, August 16, 2017

How to deploy Ubuntu Core from KVM to VirtualBox?

Steps:
1. Download Ubuntu Core of KVM image from URL below:
https://developer.ubuntu.com/core/get-started/kvm

2. To decompress xz.

3. To convert the format of img to the vdi via VBoxManage command below:

VBoxManage.exe convertdd ubuntu-core-16-amd64.img ubuntu-core-16-amd64.vdi
4. Import vdi file above to the VirtualBox without issue.



Wednesday, June 14, 2017

Python的額外錯誤處理

Example:
try:
    data=open('open_file.txt')
    for each_line in data:
        try:
            (var1,var2)=each_line.split(":",1)
            print(var1)
            print(var2)
        except:
            print(each_line)
    data.close()
except:

    print('File is not existing'

透過Python的try & except,程式碼果真變得很簡潔~

Monday, May 22, 2017

如何將Python程式模組化?

今天學習了如何將Python function模組化.
實際的步驟:
1. 撰寫python, 存檔為*.py
2. 撰寫setup.py for metadata (*.py跟setup.py需在同一個目錄下)
3. 執行python setup.py sdist 以建構發行套件檔案4. 執行python setup.py install 來安裝發行套件到本地端

開啟一個新檔案把module 用import的方式匯入, 透過引用正確的module名稱跟函式就可以執行了.

Tuesday, April 25, 2017

Cockpit

I saw this tools recently, and I am definitely to try it. :)

Cockpit


Thursday, April 06, 2017

Root file system is mounted as read only ?

I encountered this symptom and found out similar issue and solution is listed as below:

http://www.unix.com/linux/168716-root-filesystem-goes-readonly.html

Method:
fsck -p /dev/sdX

Thursday, August 27, 2015

TIPS for Expect Script

在此筆記一些Expect Script的使用技巧。

1. 記錄Expect Script執行的過程:
 log_file -noappend ./$0.log
.......
.......
.......
log_file
2. 與遠端主機斷線:
expect eof
3.  For loop於Expect Script的用法:
expect -c "
for {set i 1} {\$i <= 10} {incr i 1} {

}
"
4. If於Expect Script的用法:
expect -c "
  if { \$i == 1 } {

 }
5. 於Expect Script跳脫"符號的方法:
expect -c
send \"test \\\"test\\ test\\ test\\\"\r\"
"

Tuesday, August 25, 2015

如何讓rsyslog 也支援TCP?

預設rsyslog只支援UDP with port 514,如果要支援TCP,可以載入TCP的模組即可使用。

$ModLoad imudp.so
$UDPServerRun 514

$ModLoad imtcp.so
$InputTCPServerRun 514

記得修改完畢後restart rsyslog。