<p>I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.</p>

<p>So far the only input required is a password for sudo - and gksudo handles that fine.
But I haven't found an easy way to show a message box yet. Is there some kind of 'gkmessage' command available? I'd prefer something present in a default Ubuntu install, but I don't mind installing a new package if necessary.</p>

[{'answer_id': 7041, 'author': 'Blorgbeard', 'author_id': 369, 'author_profile': 'https://Stackoverflow.com/users/369', 'pm_score': 4, 'selected': False, 'text': '<p>I found the <a href="https://linux.die.net/man/1/xmessage" rel="noreferrer">xmessage</a> command, which is sort of good enough.</p>\n'}, {'answer_id': 7043, 'author': 'Mark Harrison', 'author_id': 116, 'author_profile': 'https://Stackoverflow.com/users/116', 'pm_score': 3, 'selected': False, 'text': '<p>Here\'s a little Tcl script that will do what you want.  The Wish interpreter should be installed by default on Ubuntu.</p>\n\n<pre><code>#!/usr/bin/wish\npack [label .msg -text [lindex $argv 0]]\npack [entry .ent]\nbind .ent &lt;KeyPress-Return&gt; { puts [.ent get]; destroy . }\nfocus .ent\n</code></pre>\n\n<p>Call it like this:</p>\n\n<pre><code>myanswer=`gui-prompt "type your answer and press enter"`\n</code></pre>\n'}, {'answer_id': 7068, 'author': 'Derek Park', 'author_id': 872, 'author_profile': 'https://Stackoverflow.com/users/872', 'pm_score': 8, 'selected': True, 'text': '<p>I believe <a href="http://live.gnome.org/Zenity" rel="noreferrer">Zenity</a> will do what you want.  It\'s specifically designed for displaying GTK dialogs from the command line, and it\'s available as an <a href="http://packages.ubuntu.com/hardy/zenity" rel="noreferrer">Ubuntu package</a>.</p>\n'}, {'answer_id': 78654, 'author': 'Steve Baker', 'author_id': 13566, 'author_profile': 'https://Stackoverflow.com/users/13566', 'pm_score': 3, 'selected': False, 'text': '<p>There is also <code>dialog</code> and the KDE version <code>kdialog</code>.  <code>dialog</code> is used by slackware, so it might not be immediately available on other distributions.</p>\n'}, {'answer_id': 79199, 'author': 'Jarek', 'author_id': 14210, 'author_profile': 'https://Stackoverflow.com/users/14210', 'pm_score': 0, 'selected': False, 'text': "<p>Kdialog and dialog are both good, but I'd recommend Zenity. Quick, easy, and much better looking the xmessage or dialog. </p>\n"}, {'answer_id': 79217, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://live.gnome.org/Zenity" rel="nofollow noreferrer">Zenity</a> is really the exact tool that I think that you are looking for.</p>\n\n<p>or</p>\n\n<pre><code>zenity --help\n</code></pre>\n'}, {'answer_id': 1235050, 'author': 'Jim', 'author_id': 12419, 'author_profile': 'https://Stackoverflow.com/users/12419', 'pm_score': 6, 'selected': False, 'text': '<p>The <strong>zenity</strong> application appears to be what you are looking for. </p>\n\n<p>To take input from <strong>zenity</strong>, you can specify a variable and have the output of <strong>zenity --entry</strong> saved to it. It looks something like this:</p>\n\n<pre><code>my_variable=$(zenity --entry)\n</code></pre>\n\n<p>If you look at the value in <strong>my_variable</strong> now, it will be whatever was typed in the zenity pop up entry dialog.</p>\n\n<p>If you want to give some sort of prompt as to what the user (or you) should enter in the dialog, add the <strong>--text</strong> switch with the label that you want. It looks something like this:</p>\n\n<pre><code>my_variable=$(zenity --entry --text="What\'s my variable:")\n</code></pre>\n\n<p>Zenity has lot of other nice options that are for specific tasks, so you might want to check those out as well with <strong>zenity --help</strong>. One example is the <strong>--calendar</strong> option that let\'s you select a date from a graphical calendar.</p>\n\n<pre><code>my_date=$(zenity --calendar)\n</code></pre>\n\n<p>Which gives a nicely formatted date based on what the user clicked on:</p>\n\n<pre><code>echo ${my_date}\n</code></pre>\n\n<p>gives:</p>\n\n<blockquote>\n  <p>08/05/2009</p>\n</blockquote>\n\n<p>There are also options for slider selectors, errors, lists and so on.</p>\n\n<p>Hope this helps.</p>\n'}, {'answer_id': 14422397, 'author': 'chmac', 'author_id': 198232, 'author_profile': 'https://Stackoverflow.com/users/198232', 'pm_score': 8, 'selected': False, 'text': '<p>In many Linux distros the <code>notify-send</code> command will throw one of those nice perishable notifications in the top right corner. Like so:</p>\n<p><code>notify-send &quot;My name is bash and I rock da house&quot;</code></p>\n<p>B.e.a.utiful!</p>\n'}, {'answer_id': 21408784, 'author': 'Stéphane Gourichon', 'author_id': 1429390, 'author_profile': 'https://Stackoverflow.com/users/1429390', 'pm_score': 7, 'selected': False, 'text': '<p>Everyone mentions zenity, there seem to be many others. A mixed up but interesting list is at <a href="http://alternativeto.net/software/zenity/" rel="noreferrer">http://alternativeto.net/software/zenity/</a></p>\n<p>First, an example of zenity featuring text formatting markup, window title, button label.</p>\n<pre><code>zenity \\\n--info \\\n--text=&quot;&lt;span size=\\&quot;xx-large\\&quot;&gt;Time is $(date +%Hh%M).&lt;/span&gt;\\n\\nGet your &lt;b&gt;coffee&lt;/b&gt;.&quot; \\\n--title=&quot;Coffee time&quot; \\\n--ok-label=&quot;Sip&quot;\n</code></pre>\n<h2>gxmessage</h2>\n<pre><code>gxmessage &quot;my text&quot;\n</code></pre>\n<h2>xmessage</h2>\n<p><code>xmessage</code> is very old so it is stable and probably available in all distributions that use X (since it\'s distributed with X).  It is customizable through X resources, for those that have been using Linux or Unix for long enough to know what it means (<code>.Xdefaults</code>, anyone ?).</p>\n<pre><code>xmessage -buttons Ok:0,&quot;Not sure&quot;:1,Cancel:2 -default Ok -nearmouse &quot;Is xmessage enough for the job ?&quot; -timeout 10\n</code></pre>\n<h2>kdialog (KDE tool)</h2>\n<pre><code>kdialog --error &quot;Some error occurred&quot;\n</code></pre>\n<h2>In a PPA</h2>\n<p><a href="http://www.webupd8.org/2010/12/yad-zenity-on-steroids-display.html" rel="noreferrer">YAD: Zenity On Steroids [Display Graphical Dialogs From Shell Scripts] ~ Web Upd8: Ubuntu / Linux blog</a>. Does not seem to auto-size dialogs.</p>\n<pre><code>echo My text | yad \\\n--text-info \\\n--width=400 \\\n--height=200\n</code></pre>\n<p>An bigger example</p>\n<pre><code>yad \\\n--title=&quot;Desktop entry editor&quot; \\\n--text=&quot;Simple desktop entry editor&quot; \\\n--form \\\n--field=&quot;Type:CB&quot; \\\n--field=&quot;Name&quot; \\\n--field=&quot;Generic name&quot; \\\n--field=&quot;Comment&quot; \\\n--field=&quot;Command:FL&quot; \\\n--field=&quot;Icon&quot; \\\n--field=&quot;In terminal:CHK&quot; \\\n--field=&quot;Startup notify:CHK&quot; &quot;Application&quot; &quot;Name&quot; &quot;Generic name&quot; &quot;This is the comment&quot; &quot;/usr/bin/yad&quot; &quot;yad&quot; FALSE TRUE \\\n--button=&quot;WebUpd8:2&quot; \\\n--button=&quot;gtk-ok:0&quot; \\\n--button=&quot;gtk-cancel:1&quot;\n</code></pre>\n<h2>Others not in Ubuntu standard repositories</h2>\n<ul>\n<li>shellgui</li>\n<li>xdialog</li>\n<li>gtkdialog</li>\n</ul>\n<h2>Off-topic (for terminal)</h2>\n<pre><code>whiptail --msgbox &quot;my text&quot; 10 20\ndialog --msgbox &quot;my text&quot; 10 20\n</code></pre>\n<p>Feel free to edit.</p>\n'}, {'answer_id': 35920711, 'author': 'mulya', 'author_id': 315158, 'author_profile': 'https://Stackoverflow.com/users/315158', 'pm_score': 2, 'selected': False, 'text': "<p>How about Ubuntu's <strong>alert</strong>. It can be used after any operation to alert it finished and even show red cross icon if operaton was finnished with errors</p>\n\n<pre><code>ls -la; alert\n</code></pre>\n"}, {'answer_id': 42125720, 'author': 'Dave Thebuskeruk', 'author_id': 7537345, 'author_profile': 'https://Stackoverflow.com/users/7537345', 'pm_score': 3, 'selected': False, 'text': '<p><code>alert</code> and <code>notify-send</code> seem to be the same thing. I use <code>notify-send</code> for non-input messages as it doesn\'t steal focus and I cannot find a way to stop zenity etc. from doing this.</p>\n\n<p>e.g.\n</p>\n\n<pre><code># This will display message and then disappear after a delay:\nnotify-send "job complete"\n\n# This will display message and stay on-screen until clicked:\nnotify-send -u critical "job complete"\n</code></pre>\n'}, {'answer_id': 47193545, 'author': 'user6795571', 'author_id': 6795571, 'author_profile': 'https://Stackoverflow.com/users/6795571', 'pm_score': 3, 'selected': False, 'text': '<p>if nothing else is present. you can launch an xterm and echo in it, like this:</p>\n\n<pre><code> xterm -e bash -c \'echo "this is the message";echo;echo -n "press enter to continue "; stty sane -echo;answer=$( while ! head -c 1;do true ;done);\'\n</code></pre>\n'}, {'answer_id': 70455744, 'author': 'steve hannah', 'author_id': 2935174, 'author_profile': 'https://Stackoverflow.com/users/2935174', 'pm_score': 2, 'selected': False, 'text': '<p>You can use <a href="https://github.com/shannah/shellmarks" rel="nofollow noreferrer">shellmarks</a> to display a GUI dialog prior to your shell script running, that will allow the user to enter data that will be placed in the environment.</p>\n<pre><code>#!/bin/bash\necho &quot;Hello ${name}&quot;\nexit 0\n---\n[name]\n  type=&quot;text&quot;\n  label=&quot;Please enter your name&quot;\n  required=true\n</code></pre>\n<p>Running script:</p>\n<pre><code>shellmarks hello.sh\n</code></pre>\n<p><a href="https://i.stack.imgur.com/Gnjyq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gnjyq.png" alt="Shellmarks dialog" /></a></p>\n<p>If you enter &quot;Steve&quot; in the box and press run, the output will be</p>\n<pre><code>Hello Steve\n</code></pre>\n<p>Disclosure:  I\'m the author of Shellmarks</p>\n'}, {'answer_id': 70483900, 'author': 'Bendlas', 'author_id': 278651, 'author_profile': 'https://Stackoverflow.com/users/278651', 'pm_score': 0, 'selected': False, 'text': '<p>I\'m liking what I\'m seeing with <a href="https://github.com/lunarcloud/script-dialog" rel="nofollow noreferrer">script-dialog</a>. It ticks all my boxes, plus some:</p>\n<ul>\n<li>pop up GUI boxes, but has text-mode fallback</li>\n<li>support for various sudo variants (gksudo, kde-sudo, ...)</li>\n<li>can re-launch itself in terminal window</li>\n</ul>\n<p>Indeed it\'s a wrapper for kdialog, zenity, dialog, whiptail and a custom fall-back.</p>\n<p>Draw-back is that it doesn\'t have a CLI, but instead is meant to be sources into a bash script.</p>\n'}]
['https://Stackoverflow.com/questions/7035', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/369/']