From eb98644bedf136120c90b5c71195d4f6a80a032a Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Tue, 24 Dec 2013 16:11:10 +0100 Subject: [PATCH] Tested out dialog a bit --- Labb7/editor | 0 Labb7/test_dialog1.sh | 11 ++++++----- Labb7/test_dialog_checklist.sh | 16 ++++++++++++++++ Labb7/test_dialog_inputbox.sh | 22 ++++++++++++++++++++++ Labb7/test_dialog_menu.sh | 23 +++++++++++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 Labb7/editor create mode 100755 Labb7/test_dialog_checklist.sh create mode 100755 Labb7/test_dialog_inputbox.sh create mode 100755 Labb7/test_dialog_menu.sh diff --git a/Labb7/editor b/Labb7/editor new file mode 100644 index 0000000..e69de29 diff --git a/Labb7/test_dialog1.sh b/Labb7/test_dialog1.sh index 69cf3ec..0dd9efb 100755 --- a/Labb7/test_dialog1.sh +++ b/Labb7/test_dialog1.sh @@ -5,22 +5,23 @@ # Testing out dialog # Variables -$Dialog="/usr/bin/dialog" +Dialog="/usr/bin/dialog" # Sanity check if [ ! -x $Dialog ]; then echo "Can't execute $Dialog" + exit 2 fi # Main -dialog --backtitle "Epic App" --msgbox \ +$Dialog --backtitle "Epic App" --msgbox \ "Welcome to Epic App, hit enter to continue" 10 60 if [ $? -ne 0 ]; then echo "Quitting" exit 1 fi -dialog --backtitle "Epic App" --title "U sure?" --yesno \ +$Dialog --backtitle "Epic App" --title "U sure?" --yesno \ "Are you sure you want to continue?" 10 60 if [ $? -eq 1 ]; then echo "Okay, you said no, quitting" @@ -35,10 +36,10 @@ if [ $? -ne 0 ]; then exit 2 fi -dialog --backtitle "Epic App" --infobox "Booting up..." 10 60 +$Dialog --backtitle "Epic App" --infobox "Booting up..." 10 60 sleep 3 -dialog --backtitle "Epic App" --pause "Waiting to get ready..." 10 60 5 +$Dialog --backtitle "Epic App" --pause "Waiting to get ready..." 10 60 5 if [ $? -eq 254 ]; then echo "Ok, aborting" exit 2 diff --git a/Labb7/test_dialog_checklist.sh b/Labb7/test_dialog_checklist.sh new file mode 100755 index 0000000..d497ad3 --- /dev/null +++ b/Labb7/test_dialog_checklist.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Testing checklists in dialg + +dialog --checklist "Choose your editor" 10 60 3 \ + vi "The vi editor" off emacs "The Emacs editor" \ + off nano "The nano editor" off 2> /tmp/editorchoice +Editor=`cat /tmp/editorchoice | sed 's/\"//g'` + +echo "You chose the $Editor editor, starting" +$Editor + +exit 0 + diff --git a/Labb7/test_dialog_inputbox.sh b/Labb7/test_dialog_inputbox.sh new file mode 100755 index 0000000..d51f5b6 --- /dev/null +++ b/Labb7/test_dialog_inputbox.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Testing inputboxes + +# Binaries +Dialog="/usr/bin/dialog" + +# Santiy check +if [ ! -x $Dialog ]; then + echo "Can't execute $Dialog" + exit 2 +fi + +# Main +$Dialog --inputbox "Your name" 10 60 2> /tmp/namefrombox +Name=`cat /tmp/namefrombox` + +$Dialog --msgbox "Your name is $Name" 10 60 + +exit 0 diff --git a/Labb7/test_dialog_menu.sh b/Labb7/test_dialog_menu.sh new file mode 100755 index 0000000..65676e9 --- /dev/null +++ b/Labb7/test_dialog_menu.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Jack-Benny Persson +# LX13 +# Testing menus with dialog + +# Binaries +Dialog="/usr/bin/dialog" + +# Sanity check +if [ ! -x $Dialog ]; then + echo "Can't excute $Dialog" + exit 2 +fi + +$Dialog --menu "Choose your editor" 10 60 3 vi "The vi Editor"\ + emacs "The emacs Editor" nano "The nano Editor" 2> /tmp/editorchoice + +Editor=`cat /tmp/editorchoice` + +$Dialog --msgbox "You selected $Editor" 10 60 + +exit 0