Bash脚本跳过对话框用户输入

时间:2015-04-16 14:37:20

标签: bash dialog

我正在编写一个自动安装hadoop master和slave的安装脚本。因为我有时需要用户输入来配置IP地址等等我在安装脚本中安装'对话'。但是,脚本会跳过对话框并继续。为什么呢?

#!/bin/bash

if [ $(whoami) != "root" ];
then
    echo "Must be run as root."
    exit 1
fi

sudo apt-get update
sudo apt-get -y upgrade

sudo apt-get install -y dialog

choice=`dialog --clear --backtitle -"bla bla" --radiolist "Hadoop Install" 10 40 3 1 "Master" on "Slave" off 3>&1 1>&2 2>&3`
dialog --clear
clear

TYPE="hadoopmaster"

case $choice in
    1)  echo "Master"
        TYPE="hadoopmaster";;
    2)  number=`dialog --clear --backtitle -"blaa" --  
        inputbox "Slave Number" 0 0 "" 3>&1 1>&2 2>&3`
        dialog --clear
        clear
        TYPE="hadoopslave"$number;;
esac

apt-get update
apt-get install -y curl
apt-get install -y git 

1 个答案:

答案 0 :(得分:0)

正确的命令是:

choice=`dialog --clear --backtitle -"bla bla" --radiolist "Hadoop Install" 10 40 3 1 "Master" on 2 "Slave" off 3>&1 1>&2 2>&3`

谢谢你们!