2017年9月3日 星期日

bash script array sample

To declare an array in bash

Declare and an array called array and assign three values:
array=( one two three )
More examples:
files=( "/etc/passwd" "/etc/group" "/etc/hosts" )
limits=( 10, 20, 26, 39, 48)
To print an array use:
printf "%s\n" "${array[@]}"
printf "%s\n" "${files[@]}"
printf "%s\n" "${limits[@]}"

To Iterate Through Array Values

Use for loop syntax as follows:
for i in "${arrayName[@]}"
do
   : 
   # do whatever on $i
done
$i will hold each item in an array. Here is a sample working script:
#!/bin/bash
# declare an array called array and define 3 vales
array=( one two three )
for i in "${array[@]}"
do
 echo $i
done

2017年8月17日 星期四

Windows10 & 2016 WOL

關於Windows10之後Wake on lan失效問題,請到下面連結下載
Win10 Auto Installation Program的realtek driver,安裝之後問題解決,也不用像其他資料寫得要改green ethernet或者Windows10的fast boot。


Win10 Auto Installation Program (SharedID:
1152921504607292454SId:1152921504626816921)
10.0192017/7/2710404kGlobal

2017年8月8日 星期二

bash script sample

Bash Script 檔案及目錄是否存在



檢查檔案是否存在

2017年8月3日 星期四

dpkg-reconfigure dash

dpkg-reconfigure dash

Ubuntu / Debian 發行版本預設都使用 dash 作為 shell,但若使用 bash 習慣的人必定要執行此指令,choice No 將預設 shell 改為 bash! 

dpkg-reconfigure locales

本土化語言設定。

dpkg-reconfigure tzdata

時區設定。

dpkg-reconfigure exim4-config

設定 Mail Transfer Agent(MTA)。

dpkg-reconfigure console-setup

設定 console 的字型、編碼等

dpkg-reconfigure gdm/lightdm

設定 display manager。目前 Ubuntu 預設為 lightdm,舊版為 gdm(gnome display manager。

dpkg-reconfigure openssh-server

重新產生 SSH server RSA 與 DSA key。

dpkg-reconfigure wireshark

安裝 wireshark 完成後,必須要使用 root 才可以順利擷取到網路介面封包,透過此命令可以設定一般使用者也可以正常操作

2017年8月1日 星期二

bash script sample

1.create a select menu in a shell script?

#!/bin/bash

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice 1"
            ;;
        "Option 2")
            echo "you chose choice 2"
            ;;
        "Option 3")
            echo "you chose choice 3"
            ;;
        "Quit")
            break
            ;;
        *) echo invalid option;;
    esac
done

2.create a Function in a shell script?

#!/bin/bash
           function quit {
               exit
           }
           function hello {
               echo Hello!
           }
           hello
           quit
           echo foo 

2017年7月4日 星期二

WakeMeOnLan

1.WakeMeOnLan此工具可以讓您藉由傳送網路喚醒(Wake-on-LAN,WOL)封包來遠端開機。當全部電腦開機時,此工具會掃描網路並收集電腦MAC位址,並將MAC位址資料儲存下來。事後,當電腦關機或在待機模式時,你可以使用儲存下來的電腦MAC位址來輕鬆選擇你想開啟的電腦。 

【軟體名稱】:WakeMeOnLan 
【軟體版本】:1.65
【軟體分類】:網路工具
【軟體介面】:繁體中文
【軟體性質】:免費軟體
【檔案大小】:434KB
【作業系統】:Windows


【官方網址】:http://www.nirsoft.net/utils/wake_on_lan.html

【免安裝版】 [按此下載]

使用前Enable Wake On LAN 

MAC & IP EX: 
00-xx-c0-xx-49-1b
192.168.x.x







2017年6月22日 星期四

USB DOS開機片

一.
1.首先先下載下面程式       解壓縮後得到
2.執行 HPUSBFW.EXE



下載:
Download


-------------------------------------------------------------------------------

二.EFI開機隨身碟















下載:內有使用說明文件
Download