2012年10月16日 星期二

Virtualbox的網路設定

1. 如果guest使用NAT方式,guest會使用host網路上網,但現在在公司內如果host使用有線網路,guest是無法利用host上網,假如host改用wifi連外網,即可讓guest透過host的wifi連出去。可利用此方式讓guest OS可以連上internet做些更新。

2. 如果guest使用橋接介面卡方式,則會讓guest模擬一張網卡,可透過host的網卡向DHCP server要到一組實體IP。

3. 如果單純只是要讓host可以與guest相連,如http server,則可使用僅限主機介面卡,這可讓guest產生一組192.168.56.101的虛擬IP,此時host即可使用這虛擬IP與guest相連接。

2012年10月1日 星期一

The notes to write Linux shell

1. Convert hex byte to decimal format
a=0x30
b=`printf %i $a`
echo $b

2. Convert ASCII code byte to the char.
a=0x61
b=`printf %i $a | awk '{printf("%c\n", $1)}'`
echo $b

3. Convert the char to ASCII code byte
a="abcde"
a_len=`expr length "$a"`

for (( i=1; i<=$a_len; i=i+1  ))
do
                index=$i
                each_char=`expr substr $a $i 1`
                each_char_ascii=`printf %s $each_char | od -A n -t x1 | tr -d ' '`
                echo "$each_char_ascii "


done

4.