On Fri, 14 Nov 2003 21:43:50 +0700 Fajar Priyanto <[EMAIL PROTECTED]> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Dear All, > Can we make menu in bash script just like in DOS' batch file? > Such as: > ======= > [Menu] > Pls select what you want to do: > 1. Copy /etc/dhcpd.conf > 2. Copy /etc/wvdial.conf > 3. Make directory /var/log/nullmailer > 4. Do all of above > ====== > Could you please give me some examples? > Thanks > - -- this script allows you to choose an action with arrow keys then select with enter or quit with Q replace the actions to do in the last case statement with what you want. bye jipe ---------------- the script -------------------------- :) #!/bin/bash #menu.sh clear echo " Please select an action" echo menuA[1]="$(echo -e " \e[1;34;46m-1-\e[0m\tCopy /etc/dhcpd.conf")" menuB[1]="$(echo -e " \e[1;34;47m-1-\e[0m\tCopy /etc/dhcpd.conf")" menuA[2]="$(echo -e " \e[1;34;46m-2-\e[0m\tCopy /etc/wvdial.conf")" menuB[2]="$(echo -e " \e[1;34;47m-2-\e[0m\tCopy /etc/wvdial.conf")" menuA[3]="$(echo -e " \e[1;34;46m-3-\e[0m\tMake directory /var/log/nullmailer")" menuB[3]="$(echo -e " \e[1;34;47m-3-\e[0m\tMake directory /var/log/nullmailer")" menuA[4]="$(echo -e " \e[1;34;46m-4-\e[0m\tDo all of above")" menuB[4]="$(echo -e " \e[1;34;47m-4-\e[0m\tDo all of above")" echo "${menuA[1]}" echo "${menuA[2]}" echo "${menuA[3]}" echo "${menuA[4]}" action=1 V=1 v=1 echo -en "\e[$((V+2));1H${menuB[V]}" while ((action)); do read -s -n1 R1 case $R1 in $'\x1b') read -s -n1 R2 case $R2 in $'\x5b') read -s -n1 R3 case $R3 in $'\x41') ((V--)) ;; $'\x42') ((V++)) ;; *) continue ;; esac ;; *) continue ;; esac ;; [qQ]) clear; exit 63 ;; "") action=0 ;; *) continue ;; esac if [ $V = 0 ]; then V=4; fi if [ $V = 5 ]; then V=1; fi echo -en "\e[$((v+2));1H${menuA[v]}" echo -en "\e[$((V+2));1H${menuB[V]}" v=$V case $action in 0) clear case $V in 1) echo Copying /etc/dhcpd.conf ;; 2) echo Copying /etc/wvdial.conf ;; 3) echo Making directory /var/log/nullmailer ;; 4) echo Doing all of above ;; esac esac done exit 0
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com