LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2013, 02:47 AM   #1
AN28
Member
 
Registered: Apr 2013
Posts: 93

Rep: Reputation: 0
Dialog Utility --help needed!


Hi,

Has anyone tried using the dialog utility ??

I tried implementing a few box options available but I can't seem to figure our how to activate the help button.

e.g: If implement a menu box as given below, then how can I give an action to the help button? I tried adding the help button exit status "2" to the case statement but it doesn't get activated :-/

Code:
function test(){
	dialog --clear  --help-button --backtitle "" \--title "" \--menu "\n\n:" 30 60 15 \
	Menu_1 "" \
	Menu_2 "" \
	Menu_3 "" \
	Menu_4 "" \
	Menu_5 "" 2>"${INPUT}"
	 
	key=$(<"${INPUT}")
	
	 case $key in 
		Menu_1)  ;;
		Menu_2)  ;;
		Menu_3)  ;;
		Menu_4)  ;;
		Menu_5) ;; break;;
	esac

	}
 
Old 10-01-2013, 07:16 PM   #2
dickey
Member
 
Registered: Jun 2009
Posts: 43

Rep: Reputation: 18
Quote:
Originally Posted by AN28 View Post
Hi,

Has anyone tried using the dialog utility ??
Hightek is old...
Dialog is at http://invisible-island.net/dialog/

Quote:
I tried implementing a few box options available but I can't seem to figure our how to activate the help button.

e.g: If implement a menu box as given below, then how can I give an action to the help button? I tried adding the help button exit status "2" to the case statement but it doesn't get activated :-/

Code:
function test(){
	dialog --clear  --help-button --backtitle "" \--title "" \--menu "\n\n:" 30 60 15 \
	Menu_1 "" \
	Menu_2 "" \
	Menu_3 "" \
	Menu_4 "" \
	Menu_5 "" 2>"${INPUT}"
        RC=$?
The help-button is detected by checking the shell variable "$?", or you could pick it
up in the case statement using a pattern like this:
Code:
	key=$(<"${INPUT}")
	
	 case $key in
                HELP*)  echo Got Help! ;;
		Menu_1)  ;;
		Menu_2)  ;;
		Menu_3)  ;;
		Menu_4)  ;;
		Menu_5) ;; break;;
	esac
	}
[/QUOTE]
 
Old 10-01-2013, 11:24 PM   #3
AN28
Member
 
Registered: Apr 2013
Posts: 93

Original Poster
Rep: Reputation: 0
Hey, thanks for the information but I still do not get the echo statement when I select HELP...

This is what I tried
Quote:
# Store menu options selected by the user
INPUT=/tmp/menu.sh.$$

# Storage file for displaying cal and date command output
OUTPUT=/tmp/output.sh.$$

# get text editor or fall back to vi_editor
vi_editor=${EDITOR-vi}

# trap and delete temp files
trap "rm $OUTPUT; rm $INPUT; exit" SIGHUP SIGINT SIGTERM

#
# Purpose - display output using msgbox
# $1 -> set msgbox height
# $2 -> set msgbox width
# $3 -> set msgbox title
#
function display_output(){
local h=${1-10} # box height default 10
local w=${2-41} # box width default 41
local t=${3-Output} # box title
dialog --backtitle "Linux Shell Script Tutorial" --title "${t}" --clear --msgbox "$(<$OUTPUT)" ${h} ${w}
}
#
# Purpose - display current system date & time
#
function show_date(){
echo "Today is $(date) @ $(hostname -f)." >$OUTPUT
display_output 6 60 "Date and Time"
}
#
# Purpose - display a calendar
#
function show_calendar(){
cal >$OUTPUT
display_output 13 25 "Calendar"
}
#
# set infinite loop
#
while true
do

### display main menu ###
dialog --clear --help-button --backtitle "Linux Shell Script Tutorial" \
--title "[ M A I N - M E N U ]" \
--menu "You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Choose the TASK" 15 50 4 \
Date/time "Displays date and time" \
Calendar "Displays a calendar" \
Editor "Start a text editor" \
Exit "Exit to the shell" 2>"${INPUT}"


rc=$?
menuitem=$(<"${INPUT}")


# make decsion
case $menuitem in
HELP*) echo "Got HELP!" ;;
Date/time) show_date;;
Calendar) show_calendar;;
Editor) $vi_editor;;
Exit) echo "Bye"; break;;
esac

done

# if temp files found, delete em
[ -f $OUTPUT ] && rm $OUTPUT
[ -f $INPUT ] && rm $INPUT
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dialog utility in linux ravis007 Linux - General 1 02-03-2010 05:22 AM
How to add two backtitle in linux dialog utility? vpatel2001 Linux - General 0 04-30-2009 05:09 AM
Linux Dialog Utility stlouis Programming 1 01-12-2008 02:46 AM
Is their a Nvidia Card display-settings dialog or utility somewhere (fedora) FocusedWolf Linux - Newbie 4 02-25-2004 01:13 PM
Kppp Dialog Setup Help Needed lmanwarren Linux - Newbie 2 10-17-2003 10:00 PM


All times are GMT -5. The time now is 10:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration