= 2010-05-30 = * [專案] '''[wiki:jazz/ClassCloud_LiveCD ClassCloud-LiveCD : 基於 DRBL 的雲端教學環境] ''' == DRBL-Hadoop Live == * 如何在 shell script 裡面安裝 java 又不用選 yes * [參考] [http://www.davidpashley.com/blog/debian/java-license Installing java non-interactively] * 這裡提到用 debconf-set-selections 來設定一些參數,讓 sun-java*-* 不問授權的 yes,方法包括有寫檔跟沒寫檔的做法,個人覺得留言裡面的那個做法最帥了!! {{{ cat << EOF | /usr/bin/debconf-set-selections sun-java6-bin shared/accepted-sun-dlj-v1-1 select true sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true sun-java6-jre shared/accepted-sun-dlj-v1-1 select true EOF }}} * 那麼如果以後遇到別的套件也有類似的問題該怎麼找參數呢?? 答案是用 debconf-get-selections 這個指令,首先必須安裝 [http://packages.debian.org/debconf-utils debconf-utils] 套件,然後執行 debconf-get-selections 再用 grep 用套件名稱找出可以改的參數。 {{{ ~$ sudo debconf-get-selections | grep sun-java6 sun-java6-jre sun-java6-jre/stopthread boolean true sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true sun-java6-jre sun-java6-jre/jcepolicy note sun-java6-bin shared/error-sun-dlj-v1-1 error sun-java6-jre shared/error-sun-dlj-v1-1 error sun-java6-bin shared/present-sun-dlj-v1-1 note sun-java6-jre shared/present-sun-dlj-v1-1 note }}} * 須注意的是原本參數是 boolean 格式,若要下給 debconf-set-selections 必須置換成 select 關鍵字喔!! {{{ ~$ sudo debconf-get-selections | grep sun-java6 | grep boolean | sed 's#boolean#select#g' sun-java6-bin shared/accepted-sun-dlj-v1-1 select true sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true sun-java6-jre shared/accepted-sun-dlj-v1-1 select true sun-java6-jre sun-java6-jre/stopthread select true }}} == Shell Script == * 如何在 shell script 裡面把標準輸入跟標準輸出重新導向到另一個路徑呢?! * [參考] [http://www.linuxquestions.org/questions/linux-general-1/shell-scripting-how-to-redirect-output-from-within-the-script-itself-446558/ Shell scripting: How to redirect output from within the script itself? ] {{{ #!sh #! /bin/bash TARGET="target-file" # file descriptor 4 prints to STDOUT and to TARGET exec 4> >(while read a; do echo $a; echo $a >>$TARGET; done) # file descriptor 5 remembers STDOUT exec 5>&1 # now STDOUT is redirected exec >&4 date # wer're done exec >&5 echo "Date sent to fd4." }}}