2010-05-30
DRBL-Hadoop Live
- 如何在 shell script 裡面安裝 java 又不用選 yes
- [參考] 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 這個指令,首先必須安裝 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 裡面把標準輸入跟標準輸出重新導向到另一個路徑呢?!
- [參考] Shell scripting: How to redirect output from within the script itself?
#! /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."
- [參考] Shell scripting: How to redirect output from within the script itself?
Last modified 14 years ago
Last modified on May 30, 2010, 11:46:55 PM