San Andreas Multiplayer.
dialog--clear
dialog --create-rcfile
dialog --print-maxsize
dialogcommon-options box-options
It has no sense to use both --textbox
and --tailbox
.
Use --textbox
to display the whole file, use --tailbox
to display only the last lines of the file.
For example, the following command will display the content of the whole file todo.txt
in a dialog textbox of size 20x80.
The dialog sources contain several samples of how to use the different box options and how they look. Just take a look into the directory samples/ of the source.
If in X, here is a post that contains a script monitors /dev/input/event
:
The important command is:
Naturally, you need to have sudo
permissions, otherwise it will become what that post suggests...
You need to use quoting to get the redirection to happen in the right place; as written, the output of the xterm
itself (which is probably empty) is being redirected. You also need to specify a shell, since xterm -e
will otherwise exec
the command directly; redirection requires the shell.
You may want to consider using something like zenity
or kdialog
instead of dialog
, in order to avoid the extra xterm
.
(And in bash
the second line is better written as x=$(< /tmp/input.$$)
.)
Dialogis a program that will let you to present a variety ofquestions or display messages using dialog boxes from ashell script. These types of dialog boxes are implemented(though not all are necessarily compiled intodialog):
calendar,checklist, dselect, editbox,form, fselect, gauge, infobox,inputbox, inputmenu, menu,mixedform, mixedgauge, msgbox(message), passwordbox, passwordform,pause, prgbox, programbox,progressbox, radiolist, tailbox,tailboxbg, textbox, timebox, andyesno (yes/no).
You can putmore than one dialog box into a script:
-
Use the '--and-widget' token to forcedialog to proceed to the next dialog unless you havepressed ESC to cancel, or
-
Simply add the tokens for the next dialog box, making achain. Dialog stops chaining when the return code from adialog is nonzero, e.g., Cancel or No (see DIAGNOSTICS).
Some widgets,e.g., checklist, will write text to dialog’soutput. Normally that is the standard error, but there areoptions for changing this: '--output-fd','--stderr' and '--stdout'.No text is written if the Cancel button (or ESC) is pressed;dialog exits immediately in that case.
All optionsbegin with '--' (two ASCII hyphens, for thebenefit of those using systems with deranged localesupport).
A'--' by itself is used as an escape, i.e.,the next token on the command-line is not treated as anoption.
dialog --title -- --Not anoption
The'--args' option tells dialog to listthe command-line parameters to the standard error. This isuseful when debugging complex scripts using the'--' and '--file', sincethe command-line may be rewritten as these are expanded.
The'--file' option tells dialog to readparameters from the file named as its value.
dialog --fileparameterfile
Blanks not within double-quotesare discarded (use backslashes to quote single characters).The result is inserted into the command-line, replacing'--file' and its option value.Interpretation of the command-line resumes from that point.If parameterfile begins with '&',dialog interprets the following text as a filedescriptor number rather than a filename.
CommonOptions
--ascii-lines
Rather than draw graphics linesaround boxes, draw ASCII '+' and '-' inthe same place. See also '--no-lines'.
--aspectratio
This gives you some controlover the box dimensions when using auto sizing (specifying 0for height and width). It represents width / height. Thedefault is 9, which means 9 characters wide to every 1 linehigh.
--backtitlebacktitle
Specifies a backtitlestring to be displayed on the backdrop, at the top of thescreen.
--beginy x
Specify the position of theupper left corner of a dialog box on the screen.
--cancel-labelstring
Override the label used for'Cancel' buttons.
--clear
Clears the widget screen,keeping only the screen_color background. Use this when youcombine widgets with '--and-widget' toerase the contents of a previous widget on the screen, so itwon’t be seen under the contents of a followingwidget. Understand this as the complement of'--keep-window'. To compare the effects,use these:
All threewidgets visible, staircase effect, ordered 1,2,3:
dialog
--begin 2 2 --yesno ' 0 0
--and-widget --begin 4 4 --yesno ' 0 0
--and-widget --begin 6 6 --yesno ' 0 0
Only the lastwidget is left visible:
dialog
--clear --begin 2 2 --yesno ' 0 0
--and-widget --clear --begin 4 4 --yesno ' 0 0
--and-widget --begin 6 6 --yesno ' 0 0
All threewidgets visible, staircase effect, ordered 3,2,1:
dialog
--keep-window --begin 2 2 --yesno ' 0 0
--and-widget --keep-window --begin 4 4 --yesno '0 0
--and-widget --begin 6 6 --yesno ' 0 0
First and thirdwidget visible, staircase effect, ordered 3,1:
dialog
--keep-window --begin 2 2 --yesno ' 0 0
--and-widget --clear --begin 4 4 --yesno ' 0 0
--and-widget --begin 6 6 --yesno ' 0 0
Note, if youwant to restore original console colors and send your cursorhome after the dialog program has exited, use theclear (1) command.
--colors
Interpret embedded'Z' sequences in the dialog text by the followingcharacter, which tells dialog to set colors or videoattributes: 0 through 7 are the ANSI used in curses: black,red, green, yellow, blue, magenta, cyan and whiterespectively. Bold is set by ’b’, reset by’B’. Reverse is set by ’r’, reset by’R’. Underline is set by ’u’, resetby ’U’. The settings are cumulative, e.g.,'ZbZ1' makes the following text bold (perhapsbright) red. Restore normal settings with'Zn'.
--column-separatorstring
Tell dialog to splitdata for radio/checkboxes and menus on the occurrences ofthe given string, and to align the split data intocolumns.
--cr-wrap
Interpret embedded newlines inthe dialog text as a newline on the screen. Otherwise,dialog will only wrap lines where needed to fitinside the text box. Even though you can control line breakswith this, Dialog will still wrap any lines that aretoo long for the width of the box. Without cr-wrap, thelayout of your text may be formatted to look nice in thesource code of your script without affecting the way it willlook in the dialog.
See also the'--no-collapse' and'--trim' options.
--create-rcfile
When dialog supportsrun-time configuration, this can be used to dump a sampleconfiguration file to the file specified by file.
--date-formatformat
If the host providesstrftime, this option allows you to specify theformat of the date printed for the --calendar widget.The time of day (hour, minute, second) are the current localtime.
--defaultno
Make the default value of theyes/no box a No. Likewise, make the defaultbutton of widgets that provide 'OK' and'Cancel' a Cancel. If'--nocancel' or'--visit-items' are given those optionsoverrides this, making the default button always'Yes' (internally the same as 'OK').
--default-itemstring
Set the default item in achecklist, form or menu box. Normally the first item in thebox is the default.
--exit-labelstring
Override the label used for'EXIT' buttons.
--extra-button
Show an extra button, between'OK' and 'Cancel' buttons.
--extra-labelstring
Override the label used for'Extra' buttons. Note: for inputmenu widgets, thisdefaults to 'Rename'.
--help
Prints the help message to the standard output andexits. The help message is also printed if no options aregiven, or if an unrecognized option is given.
--help-button
Show a help-button after'OK' and 'Cancel' buttons, i.e., inchecklist, radiolist and menu boxes. If'--item-help' is also given, on exit thereturn status will be the same as for the 'OK'button, and the item-help text will be written todialog’s output after the token'HELP'. Otherwise, the return status will indicatethat the Help button was pressed, and no messageprinted.
--help-labelstring
Override the label used for'Help' buttons.
--help-status
If the help-button is selected,writes the checklist, radiolist or form information afterthe item-help 'HELP' information. This can be usedto reconstruct the state of a checklist after processing thehelp request.
--hfilefilename
Display the given file using atextbox when the user presses F1.
--hlinestring
Display the given stringcentered at the bottom of the widget.
--ignore
Ignore options thatdialog does not recognize. Some well-known ones suchas '--icon' are ignored anyway, but this isa better choice for compatibility with otherimplementations.
--input-fdfd
Read keyboard input from thegiven file descriptor. Most dialog scripts read fromthe standard input, but the gauge widget reads a pipe (whichis always standard input). Some configurations do not workproperly when dialog tries to reopen the terminal.Use this option (with appropriate juggling offile-descriptors) if your script must work in that type ofenvironment.
--insecure
Makes the password widgetfriendlier but less secure, by echoing asterisks for eachcharacter.
--item-help
Interpret the tags data forchecklist, radiolist and menu boxes adding a column which isdisplayed in the bottom line of the screen, for thecurrently selected item.
--keep-tite
When built with ncurses,dialog normally checks to see if it is running in anxterm, and in that case tries to suppress theinitialization strings that would make it switch to thealternate screen. Switching between the normal and alternatescreens is visually distracting in a script which runsdialog several times. Use this option to allowdialog to use those initialization strings.
--keep-window
Normally when dialogperforms several tailboxbg widgets connected by'--and-widget', it clears the old widgetfrom the screen by painting over it. Use this option tosuppress that repainting.
At exit,dialog repaints all of the widgets which have beenmarked with '--keep-window', even if theyare not tailboxbg widgets. That causes them to berepainted in reverse order. See the discussion of the'--clear' option for examples.
--max-inputsize
Limit input strings to thegiven size. If not specified, the limit is 2048.
--no-cancel
--nocancel
Suppress the 'Cancel'button in checklist, inputbox and menu box modes. A scriptcan still test if the user pressed the ESC key to cancel toquit.
--no-collapse
Normally dialog convertstabs to spaces and reduces multiple spaces to a single spacefor text which is displayed in a message boxes, etc. Usethis option to disable that feature. Note that dialogwill still wrap text, subject to the'--cr-wrap' and '--trim'options.
--no-kill
Tells dialog to put thetailboxbg box in the background, printing its processid to dialog’s output. SIGHUP is disabled forthe background process.
--no-labelstring
Override the label used for'No' buttons.
--no-lines
Rather than draw lines aroundboxes, draw spaces in the same place. See also'--ascii-lines'.
--no-mouse
Do not enable the mouse.
--no-nl-expand
Do not convert 'n'substrings of the message/prompt text into literalnewlines.
--no-ok
--nook
Suppress the 'OK' button in checklist,inputbox and menu box modes. A script can still test if theuser pressed the 'Enter' key to accept thedata.
--no-shadow
Suppress shadows that would bedrawn to the right and bottom of each dialog box.
--ok-labelstring
Override the label used for'OK' buttons.
--output-fdfd
Direct output to the given filedescriptor. Most dialog scripts write to the standarderror, but error messages may also be written there,depending on your script.
--separatorstring
--output-separatorstring
Specify a string that willseparate the output on dialog’s output fromchecklists, rather than a newline (for --separate-output) ora space. This applies to other widgets such as forms andeditboxes which normally use a newline.
--print-maxsize
Print the maximum size ofdialog boxes, i.e., the screen size, todialog’s output. This may be used alone,without other options.
--print-size
Prints the size of each dialogbox to dialog’s output.
--print-version
Prints dialog’sversion to dialog’s output. This may be usedalone, without other options. It does not causedialog to exit by itself.
--scrollbar
For widgets holding ascrollable set of data, draw a scrollbar on itsright-margin. This does not respond to the mouse.
--separate-output
For checklist widgets, outputresult one line at a time, with no quoting. This facilitatesparsing by another program.
--separate-widgetstring
Specify a string that willseparate the output on dialog’s output fromeach widget. This is used to simplify parsing the result ofa dialog with several widgets. If this option is not given,the default separator string is a tab character.
--shadow
Draw a shadow to the right andbottom of each dialog box.
--single-quoted
Use single-quoting as needed(and no quotes if unneeded) for the output ofchecklist’s as well as the item-help text. If thisoption is not set, dialog uses double quotes aroundeach item. That requires occasional use of backslashes tomake the output useful in shell scripts.
--size-err
Check the resulting size of adialog box before trying to use it, printing the resultingsize if it is larger than the screen. (This option isobsolete, since all new-window calls are checked).
--sleepsecs
Sleep (delay) for the givennumber of seconds after processing a dialog box.
--stderr
Direct output to the standarderror. This is the default, since curses normally writesscreen updates to the standard output.
--stdout
Direct output to the standardoutput. This option is provided for compatibility withXdialog, however using it in portable scripts is notrecommended, since curses normally writes its screen updatesto the standard output. If you use this option,dialog attempts to reopen the terminal so it canwrite to the display. Depending on the platform and yourenvironment, that may fail.
--tab-correct
Convert each tab character toone or more spaces (for the textbox widget; otherwiseto a single space). Otherwise, tabs are rendered accordingto the curses library’s interpretation.
--tab-lenn
Specify the number of spacesthat a tab character occupies if the'--tab-correct' option is given. Thedefault is 8. This option is only effective for thetextbox widget.
--time-formatformat
If the host providesstrftime, this option allows you to specify theformat of the time printed for the --timebox widget.The day, month, year values in this case are for the currentlocal time.
--timeoutsecs
Timeout (exit with error code)if no user response within the given number of seconds. Thisis overridden if the background '--tailboxbg isused. A timeout of zero seconds is ignored.
--titletitle
Specifies a title stringto be displayed at the top of the dialog box.
--tracefilename
logs the command-lineparameters, keystrokes and other information to the givenfile. If dialog reads a configure file, it is loggedas well. Piped input to the gauge widget is logged.Use control/T to log a picture of the current dialogwindow.
Thedialog program handles some command-line parametersspecially, and removes them from the parameter list as theyare processed. For example, if the first option is--trace, then that is processed (and removed) beforedialog initializes the display.
--trim
eliminate leading blanks, trim literal newlines andrepeated blanks from message text.
See also the'--cr-wrap' and'--no-collapse' options.
--version
Prints dialog’sversion to the standard output, and exits. See also'--print-version'.
--visit-items
Modify the tab-traversal ofchecklist, radiobox, menubox and inputmenu to include thelist of items as one of the states. This is useful as avisual aid, i.e., the cursor position helps some users.
When thisoption is given, the cursor is initially placed on the list.Abbreviations (the first letter of the tag) apply to thelist items. If you tab to the button row, abbreviationsapply to the buttons.
--yes-labelstring
Override the label used for'Yes' buttons.
BoxOptions
All dialog boxes have at least three parameters:
text
the caption or contents of the box.
height
the height of the dialogbox.
width
the width of the dialogbox.
Otherparameters depend on the box type.
--calendartext height width day month year
A calendar box displaysmonth, day and year in separately adjustable windows. If thevalues for day, month or year are missing or negative, thecurrent date’s corresponding values are used. You canincrement or decrement any of those using the left-, up-,right- and down-arrows. Use vi-style h, j, k and l formoving around the array of days in a month. Use tab orbacktab to move between windows. If the year is given aszero, the current date is used as an initial value.
On exit, thedate is printed in the form day/month/year. The format canbe overridden using the --date-format option.
--checklisttextheight width list-height [ tag item status ]...
A checklist box issimilar to a menu box; there are multiple entriespresented in the form of a menu. Another difference is thatyou can indicate which entry is currently selected, bysetting its status to on. Instead of choosingone entry among the entries, each entry can be turned on oroff by the user. The initial on/off state of each entry isspecified by status.
On exit, a listof the tag strings of those entries that are turnedon will be printed on dialog’s output. If the'--separate-output' option is not given,the strings will be quoted to make it simple for scripts toseparate them. See the '--single-quoted'option, which modifies the quoting behavior.
--dselectfilepathheight width
The directory-selection dialogdisplays a text-entry window in which you can type adirectory, and above that a windows with directorynames.
Herefilepath can be a filepath in which case thedirectory window will display the contents of the path andthe text-entry window will contain the preselecteddirectory.
Use tab orarrow keys to move between the windows. Within the directorywindow, use the up/down arrow keys to scroll the currentselection. Use the space-bar to copy the current selectioninto the text-entry window.
Typing anyprintable characters switches focus to the text-entrywindow, entering that character as well as scrolling thedirectory window to the closest match.
Use a carriagereturn or the 'OK' button to accept the currentvalue in the text-entry window and exit.
On exit, thecontents of the text-entry window are written todialog’s output.
--editboxfilepathheight width
The edit-box dialog displays acopy of the file. You may edit it using thebackspace, delete and cursor keys to correcttyping errors. It also recognizes pageup/pagedown. Unlikethe --inputbox, you must tab to the 'OK' or'Cancel' buttons to close the dialog. Pressing the'Enter' key within the box will split thecorresponding line.
On exit, thecontents of the edit window are written todialog’s output.
--formtext heightwidth formheight [ label y x item y x flen ilen ]...
The form dialog displaysa form consisting of labels and fields, which are positionedon a scrollable window by coordinates given in the script.The field length flen and input-length ilentell how long the field can be. The former defines thelength shown for a selected field, while the latter definesthe permissible length of the data entered in the field.
-
If flen is zero, the corresponding field cannotbe altered. and the contents of the field determine thedisplayed-length.
-
If flen is negative, the corresponding fieldcannot be altered, and the negated value of flen isused as the displayed-length.
-
If ilen is zero, it is set to flen.
Use up/downarrows (or control/N, control/P) to move between fields. Usetab to move between windows.
On exit, thecontents of the form-fields are written todialog’s output, each field separated by anewline. The text used to fill non-editable fields(flen is zero or negative) is not written out.
--fselectfilepathheight width
The fselect(file-selection) dialog displays a text-entry window inwhich you can type a filename (or directory), and above thattwo windows with directory names and filenames.
Herefilepath can be a filepath in which case the file anddirectory windows will display the contents of the path andthe text-entry window will contain the preselectedfilename.
Use tab orarrow keys to move between the windows. Within the directoryor filename windows, use the up/down arrow keys to scrollthe current selection. Use the space-bar to copy the currentselection into the text-entry window.
Typing anyprintable characters switches focus to the text-entrywindow, entering that character as well as scrolling thedirectory and filename windows to the closest match.
Typing thespace character forces dialog to complete the currentname (up to the point where there may be a match againstmore than one entry).
Use a carriagereturn or the 'OK' button to accept the currentvalue in the text-entry window and exit.
On exit, thecontents of the text-entry window are written todialog’s output.
--gaugetext heightwidth [percent]
A gauge box displays ameter along the bottom of the box. The meter indicates thepercentage. New percentages are read from standard input,one integer per line. The meter is updated to reflect eachnew percentage. If the standard input reads the string'XXX', then the first line following is taken asan integer percentage, then subsequent lines up to another'XXX' are used for a new prompt. The gauge exitswhen EOF is reached on the standard input.
Thepercent value denotes the initial percentage shown inthe meter. If not specified, it is zero.
On exit, notext is written to dialog’s output. The widgetaccepts no input, so the exit status is always OK.
--infoboxtext heightwidth
An info box is basicallya message box. However, in this case, dialogwill exit immediately after displaying the message to theuser. The screen is not cleared when dialog exits, sothat the message will remain on the screen until the callingshell script clears it later. This is useful when you wantto inform the user that some operations are carrying on thatmay require some time to finish.
On exit, notext is written to dialog’s output. Only an'OK' button is provided for input, but an ESC exitstatus may be returned.
--inputboxtextheight width [init]
An input box is usefulwhen you want to ask questions that require the user toinput a string as the answer. If init is supplied it is usedto initialize the input string. When entering the string,the backspace, delete and cursor keys can beused to correct typing errors. If the input string is longerthan can fit in the dialog box, the input field will bescrolled.
On exit, theinput string will be printed on dialog’soutput.
--inputmenutextheight width menu-height [ tag item ]...
An inputmenu box is verysimilar to an ordinary menu box. There are only a fewdifferences between them:
1.
The entries are not automatically centered but leftadjusted.
2.
An extra button (called Rename) is implied torename the current item when it is pressed.
3.
It is possible to rename the current entry by pressingthe Rename button. Then dialog will write thefollowing on dialog’s output.
RENAMED<tag> <item>
--menutext heightwidth menu-height [ tag item ] ...
As its name suggests, amenu box is a dialog box that can be used to presenta list of choices in the form of a menu for the user tochoose. Choices are displayed in the order given. Each menuentry consists of a tag string and an itemstring. The tag gives the entry a name to distinguishit from the other entries in the menu. The item is ashort description of the option that the entry represents.The user can move between the menu entries by pressing thecursor keys, the first letter of the tag as ahot-key, or the number keys 1-9. There aremenu-height entries displayed in the menu at onetime, but the menu will be scrolled if there are moreentries than that.
On exit thetag of the chosen menu entry will be printed ondialog’s output. If the'--help-button' option is given, thecorresponding help text will be printed if the user selectsthe help button.
--mixedformtextheight width formheight [ label y x item y x flenilen itype ] ...
The mixedform dialogdisplays a form consisting of labels and fields, much likethe --form dialog. It differs by adding a field-typeparameter to each field’s description. Each bit in thetype denotes an attribute of the field:
1
hidden, e.g., a password field.
2
readonly, e.g., a label.
--mixedgaugetextheight width percent [ tag1 item1 ]...
A mixedgauge boxdisplays a meter along the bottom of the box. The meterindicates the percentage.
It alsodisplays a list of the tag- and item-values atthe top of the box. See dialog(3) for the tag values.
The textis shown as a caption between the list and meter. Thepercent value denotes the initial percentage shown inthe meter.
No provision ismade for reading data from the standard input as--gauge does.
On exit, notext is written to dialog’s output. The widgetaccepts no input, so the exit status is always OK.
--msgboxtext heightwidth
A message box is verysimilar to a yes/no box. The only difference betweena message box and a yes/no box is that amessage box has only a single OK button. Youcan use this dialog box to display any message you like.After reading the message, the user can press theENTER key so that dialog will exit and thecalling shell script can continue its operation.
If the messageis too large for the space, dialog may allow you toscroll it, provided that the underlying cursesimplementation is capable enough. In this case, a percentageis shown in the base of the widget.
On exit, notext is written to dialog’s output. Only an'OK' button is provided for input, but an ESC exitstatus may be returned.
--pausetext heightwidth seconds
A pause box displays ameter along the bottom of the box. The meter indicates howmany seconds remain until the end of the pause. The pauseexits when timeout is reached or the user presses the OKbutton (status OK) or the user presses the CANCEL button orEsc key.
--passwordboxtextheight width [init]
A password box issimilar to an input box, except that the text the userenters is not displayed. This is useful when prompting forpasswords or other sensitive information. Be aware that ifanything is passed in 'init', it will be visiblein the system’s process table to casual snoopers.Also, it is very confusing to the user to provide them witha default password they cannot see. For these reasons, using'init' is highly discouraged. See'--insecure' if you do not care about yourpassword.
On exit, theinput string will be printed on dialog’soutput.
--passwordformtextheight width formheight [ label y x item y x flenilen ] ...
This is identical to--form except that all text fields are treated aspassword widgets rather than inputboxwidgets.
--prgboxtext commandheight width
--prgboxcommand height width
A prgbox is very similarto a programbox.
This dialog boxis used to display the output of a command that is specifiedas an argument to prgbox.
After thecommand completes, the user can press the ENTER keyso that dialog will exit and the calling shell scriptcan continue its operation.
If threeparameters are given, it displays the text under the title,delineated from the scrolling file’s contents. If onlytwo parameters are given, this text is omitted.
--programboxtextheight width
--programboxheight width
A programbox is verysimilar to a progressbox. The only difference betweena program box and a progress box is that aprogram box displays an OK button (but onlyafter the command completes).
This dialog boxis used to display the piped output of a command. After thecommand completes, the user can press the ENTER keyso that dialog will exit and the calling shell scriptcan continue its operation.
If threeparameters are given, it displays the text under the title,delineated from the scrolling file’s contents. If onlytwo parameters are given, this text is omitted.
--progressboxtextheight width
--progressboxheight width
A progressbox is similarto an tailbox, except that
a) rather than displaying the contents of a file,
it displays the piped output ofa command and
b) it will exit when it reachesthe end of the file
(there is no 'OK'button).
If threeparameters are given, it displays the text under the title,delineated from the scrolling file’s contents. If onlytwo parameters are given, this text is omitted.
--radiolisttextheight width list-height [ tag item status ]...
A radiolist box issimilar to a menu box. The only difference is thatyou can indicate which entry is currently selected, bysetting its status to on.
On exit, thename of the selected item is written todialog’s output.
--tailboxfile heightwidth
Display text from a file in adialog box, as in a 'tail -f' command. Scrollleft/right using vi-style ’h’ and’l’, or arrow-keys. A ’0’ resets thescrolling.
On exit, notext is written to dialog’s output. Only an'OK' button is provided for input, but an ESC exitstatus may be returned.
--tailboxbgfileheight width
Display text from a file in adialog box as a background task, as in a 'tail -f&' command. Scroll left/right using vi-style’h’ and ’l’, or arrow-keys. A’0’ resets the scrolling.
Dialog treatsthe background task specially if there are other widgets(--and-widget) on the screen concurrently. Untilthose widgets are closed (e.g., an 'OK'),dialog will perform all of the tailboxbg widgets inthe same process, polling for updates. You may use a tab totraverse between the widgets on the screen, and close themindividually, e.g., by pressing ENTER. Once thenon-tailboxbg widgets are closed, dialog forks a copyof itself into the background, and prints its process id ifthe '--no-kill' option is given.
On exit, notext is written to dialog’s output. Only an'EXIT' button is provided for input, but an ESCexit status may be returned.
NOTE: Olderversions of dialog forked immediately and attemptedto update the screen individually. Besides being bad forperformance, it was unworkable. Some older scripts may notwork properly with the polled scheme.
--textboxfile heightwidth
A text box lets youdisplay the contents of a text file in a dialog box. It islike a simple text file viewer. The user can move throughthe file by using the cursor, page-up, page-down andHOME/END keys available on most keyboards. If thelines are too long to be displayed in the box, theLEFT/RIGHT keys can be used to scroll the text regionhorizontally. You may also use vi-style keys h, j, k, l inplace of the cursor keys, and B or N in place of the page-upand page-down keys. Scroll up/down using vi-style’k’ and ’j’, or arrow-keys. Scrollleft/right using vi-style ’h’ and’l’, or arrow-keys. A ’0’ resets theleft/right scrolling. For more convenience, vi-style forwardand backward searching functions are also provided.
On exit, notext is written to dialog’s output. Only an'EXIT' button is provided for input, but an ESCexit status may be returned.
--timeboxtext height[width hour minute second]
A dialog is displayed whichallows you to select hour, minute and second. If the valuesfor hour, minute or second are missing or negative, thecurrent date’s corresponding values are used. You canincrement or decrement any of those using the left-, up-,right- and down-arrows. Use tab or backtab to move betweenwindows.
On exit, theresult is printed in the form hour:minute:second. The formatcan be overridden using the --time-format option.
--yesnotext heightwidth
A yes/no dialog box ofsize height rows by width columns will bedisplayed. The string specified by text is displayedinside the dialog box. If this string is too long to fit inone line, it will be automatically divided into multiplelines at appropriate places. The text string can alsocontain the sub-string 'n' or newlinecharacters ’n’ to control line breakingexplicitly. This dialog box is useful for asking questionsthat require the user to answer either yes or no. The dialogbox has a Yes button and a No button, in whichthe user can switch between by pressing the TABkey.
On exit, notext is written to dialog’s output. In additionto the 'Yes' and 'No' exit codes (seeDIAGNOSTICS) an ESC exit status may be returned.
The codes usedfor 'Yes' and 'No' match those used for'OK' and 'Cancel', internally nodistinction is made.
ObsoleteOptions
--beep
This was used to tell the original cdialog that itshould make a beep when the separate processes of thetailboxbg widget would repaint the screen.
--beep-after
Beep after a user has completeda widget by pressing one of the buttons.
You may want to write scripts which run with other dialog 'clones'.
ORIGINAL DIALOG
First, there is the 'original' dialog program to consider (versions 0.3 to 0.9). It had some misspelled (or inconsistent) options. The dialog program maps those deprecated options to the preferred ones. They include:
XDIALOG
Technically, 'Xdialog', this is an X application. With some care, it is possible to write useful scripts that work with both Xdialog and dialog.
The dialog program ignores these options which are recognized by Xdialog:
Xdialog’s manpage has a section discussing its compatibility with dialog.
WHIPTAIL
Then there is whiptail. For practical purposes, it is maintained by Debian. Its documentation claims
whiptail(1) is a lightweight replacement for dialog(1),
to provide dialog boxes for shell scripts.
It is built on the
newt windowing library rather than the ncurses library, allowing
it to be smaller in embedded enviroments such as installers,
rescue disks, etc.
whiptail is designed to be drop-in compatible with dialog, but
has less features: some dialog boxes are not implemented, such
as tailbox, timebox, calendarbox, etc.
Comparing actual sizes (Debian testing, 2007/1/10): The total of sizes for whiptail, the newt, popt and slang libraries is 757kb. The comparable number for dialog (counting ncurses) is 520kb. Disregard the first paragraph.
The second paragraph is misleading, since whiptail also does not work for common options of dialog, such as the gauge box. whiptail is less compatible with dialog than the decade-old original dialog 0.4 program.
whiptail’s manpage borrows features from dialog, e.g., --default-item (2000), --output-fd (2002), but oddly cites only dialog versions up to 0.4 (1996) as a source. That is, its manpage refers to features which were borrowed from more recent versions of dialog, e.g., the --gauge and --password boxes, as well as options such as --separate-output (2008). Somewhat humorously, one may note that the popt feature (undocumented in its manpage) of using a '--' as an escape was documented in dialog’s manpage about a year before it was mentioned in whiptail’s manpage. whiptail’s manpage incorrectly attributes that to getopt (and is inaccurate anyway).
Debian uses whiptail for the official dialog variation.
The dialog program ignores or maps these options which are recognized by whiptail:
Kiran Cherupally - the mixed form and mixed gauge widgets.
Tobias C. Rittweiler
Valery Reznic - the form and progressbox widgets.
Yura Kalinichenko adapted the gauge widget as 'pause'.
This is a rewrite (except as needed to provide compatibility) of the earlier version of dialog 0.9a, which lists as authors:
Savio Lam - version 0.3, 'dialog'
Stuart Herbert - patch for version 0.4
Marc Ewing - the gauge widget.
Pasquale De Marco 'Pako' - version 0.9a, 'cdialog'
Exit status is subject to being overridden by environment variables. The default values and corresponding environment variables that can override them are:
0
if dialog is exited by pressing the Yes or OK button (DIALOG_OK).
1
if the No or Cancel button is pressed (DIALOG_CANCEL).
2
if the Help button is pressed (DIALOG_HELP).
3
if the Extra button is pressed (DIALOG_EXTRA).
4
if the Help button is pressed (DIALOG_HELP), or the --item-help option is set when the Help button is pressed (DIALOG_ITEM_HELP),
-1
if errors occur inside dialog (DIALOG_ERROR) or dialog is exited by pressing the ESC key (DIALOG_ESC).
Define this variable to apply any of the common options to each widget. Most of the common options are reset before processing each widget. If you set the options in this environment variable, they are applied to dialog’s state after the reset. As in the '--file' option, double-quotes and backslashes are interpreted.
The '--file' option is not considered a common option (so you cannot embed it within this environment variable).
Define this variable if you want to specify the name of the configuration file to use.
DIALOG_ITEM_HELP
DIALOG_OK
Define any of these variables to change the exit code on Cancel (1), error (-1), ESC (255), Extra (3), Help (2), Help with --item-help (2), or OK (0). Normally shell scripts cannot distinguish between -1 and 255.
DIALOG_TTY
Set this variable to '1' to provide compatibility with older versions of dialog which assumed that if the script redirects the standard output, that the '--stdout' option was given.
$HOME/.dialogrc
default configuration file
You can override or add to key bindings in dialog by adding to the configuration file. Dialog’s bindkey command maps single keys to its internal coding.
bindkey widget curses_key dialog_key
The widget name can be '*' (all widgets), or specific widgets such as textbox. Specific widget bindings override the '*' bindings. User-defined bindings override the built-in bindings.
The curses_key can be any of the names derived from curses.h, e.g., 'HELP' from 'KEY_HELP'. Dialog also recognizes ANSI control characters such as '^A', '^?', as well as C1-controls such as '~A' and '~?'. Finally, it allows any single character to be escaped with a backslash.
Dialog’s internal keycode names correspond to the DLG_KEYS_ENUM type in dlg_keys.h, e.g., 'HELP' from 'DLGK_HELP'.
Widget Names
Some widgets (such as the formbox) have an area where fields can be edited. Those are managed in a subwindow of the widget, and may have separate keybindings from the main widget because the subwindows are registered using a different name.
Some widgets are actually other widgets, using internal settings to modify the behavior. Those use the same widget name as the actual widget:
Built-in Bindings
This manual page does not list the key bindings for each widget, because that detailed information can be obtained by running dialog. If you have set the --trace option, dialog writes the key-binding information for each widget as it is registered.
Example
Normally dialog uses different keys for navigating between the buttons and editing part of a dialog versus navigating within the editing part. That is, tab (and back-tab) traverse buttons (or between buttons and the editing part), while arrow keys traverse fields within the editing part. Tabs are also recognized as a special case for traversing between widgets, e.g., when using multiple tailboxbg widgets.
Some users may wish to use the same key for traversing within the editing part as for traversing between buttons. The form widget is written to support this sort of redefinition of the keys, by adding a special group in <code>dlgk_keys.h</code> for 'form' (left/right/next/prev). Here is an example binding demonstrating how to do this:
bindkey formfield TAB form_NEXT
bindkey formbox TAB form_NEXT
bindkey formfield BTAB form_prev
bindkey formbox BTAB form_prev
That type of redefinition would not be useful in other widgets, e.g., calendar, due to the potentially large number of fields to traverse.
Dialog works with X/Open curses. However, some implementations have deficiencies:
-
HPUX curses (and perhaps others) do not open the terminal properly for the newterm function. This interferes with dialog’s --input-fd option, by preventing cursor-keys and similar escape sequences from being recognized.
-
NetBSD 5.1 curses has incomplete support for wide-characters. dialog will build, but not all examples display properly.
1.
Create a sample configuration file by typing:
'dialog --create-rc <file>'
2.
At start, dialog determines the settings to use as follows:
a)
if environment variable DIALOGRC is set, its value determines the name of the configuration file.
b)
if the file in (a) is not found, use the file $HOME/.dialogrc as the configuration file.
c)
if the file in (b) is not found, try using the GLOBALRC file determined at compile-time, i.e., /etc/dialogrc.
d)
if the file in (c) is not found, use compiled in defaults.
3.
Edit the sample configuration file and copy it to some place that dialog can find, as stated in step 2 above.
Perhaps.
Thomas E.Dickey (updates for 0.9b and beyond)