Comments on: Bash – Getting Input From the User http://www.terminally-incoherent.com/blog/2006/08/21/bash-getting-input-from-the-user/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Johnny Rosenberg http://www.terminally-incoherent.com/blog/2006/08/21/bash-getting-input-from-the-user/#comment-11157 Sun, 04 Jan 2009 15:27:47 +0000 http://www.terminally-incoherent.com/blog/2006/08/21/bash-getting-input-from-the-user/#comment-11157

I found the answer. It was right there in the man pages. This works:

Xdialog –stdout –title “INPUT BOX” –inputbox “What is your username?” 0 0 guraknugen > /tmp/inputbox.tmp.$$

This also works:

input=`Xdialog –stdout –title “INPUT BOX” –inputbox “What is your username?” 0 0 guraknugen`

This is nicer I think, since there is no need for temporary files. Makes the code more compact. :)

So the answer was to add –stdout to the command.

Reply  |  Quote
]]>
By: Johnny Rosenberg http://www.terminally-incoherent.com/blog/2006/08/21/bash-getting-input-from-the-user/#comment-11156 Sun, 04 Jan 2009 14:17:17 +0000 http://www.terminally-incoherent.com/blog/2006/08/21/bash-getting-input-from-the-user/#comment-11156

I tried the Xdialog example above, but it doesn’t work. After correcting the code, adding a space right before the > character to avoid an Xdialog error, the file /tmp/inputbox.tmp.$$ is created, but it remains empty. If I run the script and type Hello in the input field, the script outputs:
Hello
Input string is ”

I ran the script from a virtual console.
OS=Ubuntu 8.10.
bash –version gives this info:
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

Have anyone actually tested this? I have seen this method described on several sites now, but I just can’t make it work…
One site claimed that this is possible:
input=`Xdialog –bla bla bla`
but of course that failed too…

Reply  |  Quote
]]>