Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

yes/no dialog shell

#!/bin/sh
while true ;do
    [ -x "$(which ${DIALOG%% *})" ] || DIALOG=dialog
    DIALOG=$($DIALOG --menu "Which tool for next run?" 20 60 12 2>&1 
            whiptail       "dialog boxes from shell scripts" >/dev/tty 
            dialog         "dialog boxes from shell with ncurses" 
            gdialog        "dialog boxes from shell with Gtk" 
            kdialog        "dialog boxes from shell with Kde" ) || exit
    clear;echo "Choosed: $DIALOG."
    for i in `seq 1 100`;do
        date +"`printf "XXX
%d
%%a %%b %%T progress: %d
XXX
" $i $i`"
        sleep .0125
      done | $DIALOG --gauge "Filling the tank" 20 60 0
    $DIALOG --infobox "This is a simple info box

No action required" 20 60
    sleep 3
    if $DIALOG --yesno  "Do you like this demo?" 20 60 ;then
        AnsYesNo=Yes; else AnsYesNo=No; fi
    AnsInput=$($DIALOG --inputbox "A text:" 20 60 "Text here..." 2>&1 >/dev/tty)
    AnsPass=$($DIALOG --passwordbox "A secret:" 20 60 "First..." 2>&1 >/dev/tty)
    $DIALOG --textbox /etc/motd 20 60
    AnsCkLst=$($DIALOG --checklist "Check some..." 20 60 12 
        Correct "This demo is useful"        off 
        Fun        "This demo is nice"        off 
        Strong        "This demo is complex"        on 2>&1 >/dev/tty)
    AnsRadio=$($DIALOG --radiolist "I will:" 20 60 12 
        " -1" "Downgrade this answer"        off 
        "  0" "Not do anything"                on 
        " +1" "Upgrade this anser"        off 2>&1 >/dev/tty)
    out="Your answers:
Like: $AnsYesNo
Input: $AnsInput
Secret: $AnsPass"
    $DIALOG --msgbox "$out
Attribs: $AnsCkLst
Note: $AnsRadio" 20 60
  done
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dialog #shell
ADD COMMENT
Topic
Name
7+2 =