#!/usr/bin/env bash #===============================================================================# FILE: deploy.sh# USAGE: ./deploy.sh # DESCRIPTION: Interactive automated deployment script# OPTIONS: ---# REQUIREMENTS: ---# NOTES: ---# AUTHOR: Eric Wu, mesopodamia@gmail.com# CREATED: 01/25/2014 11:44# REVISION: ---#===============================================================================function example001() { echo "example001"}function example002() { echo "example002"}function example003() { echo "example003"}echo " ----------------------------------------"echo " "echo "Please insert function Number:"echo " "echo " [1] function001 "echo " [2] function002 "echo " [3] function003 "echo " "echo " ----------------------------------------"read Number;case "$Number" in 1) example001 && exit 0; ;; 2) example002 && exit 0; ;; 3) example003 && exit 0; ;; *) echo $"Usage: $0 {function001|function002|function003}" exit 2esacgit脚本下载地址: 第二种:dialog函数是实现的交互式
#!/usr/bin/env bash #===============================================================================# FILE: deploy.sh# USAGE: ./deploy.sh # DESCRIPTION: Interactive automated deployment script# OPTIONS: ---# REQUIREMENTS: ---# NOTES: ---# AUTHOR: Eric Wu, mesopodamia@gmail.com# CREATED: 01/25/2014 11:44# REVISION: ---#===============================================================================command -v dialogif [[ $? != 0 ]]; then yum install -y dialogfi function example001() { echo "example001"}function example002() { echo "example002"}function example003() { echo "example003"}if dialog --title "Auto Deploy System" --radiolist "Choose one function" 20 60 14 1 "function001" on 2 "function002" off 3 "function003" off 2>output; then select=`cat output` if [ $select -eq 1 ]; then example001 elif [ $select -eq 2 ]; then example002 elif [ $select -eq 3 ]; then example003 else echo "Your select is wrong!!! please try again!" fifigit脚本下载地址: