我試圖運行一個實用程序(nco_confpack),它直接在命令行上使用時效果很好。 但是,當我在shell腳本的while循環中使用相同的實用程序時,該實用程序在不接受任何輸入的情況下進入無限循環。 如何避免效用的無限循環? 下面是其工作的罰款如何在shell腳本的循環中執行輸入詢問工具?
bash-3.2$ $OMNIHOME/bin/nco_confpack -import -server SERVERA -user root -password XXXXX-select Class.list -package Class.jar
*********************************************************************
* W A R N I N G *
* *
* This action may overwrite configuration currently in your system. *
* *
* It is recommended that a backup is made of the current data *
* before importing new data. *
* *
*********************************************************************
Do you want to continue (y/n) [N]? y
bash-3.2$
然而,當相同的效用被放置在while循環要繼續(Y/N)的執行代碼段電文進入一個無限循環,而不接受任何輸入
bash-3.2$ ./classInstall.sh
Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? Do you want to continue (y/n) [N]? ^C
我在做什麼錯在這裏?這個工具有什麼問題嗎?或者我必須明確提到腳本中的某些內容?
該腳本包含的命令就是它在有限while循環下運行的命令。
bash-3.2$vi classInstall.sh
cat $1 | while read theLine
do
$OMNIHOME/bin/nco_confpack -import -server SERVERA -user root -password XXXXX-select Class.list -package Class.jar
done
$ 1包含兩個條目只有如此循環,命令預計運行兩次只
循環是否自動發生,或者只有在按下時纔會重複提示進入? –
它可能有助於顯示有問題的代碼。 – chepner
@NicolaiEhemann循環在接受用戶/提示的任何內容之前自動發生。 –