Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible from a background shell script to open a new terminal (xterm, gnome-terminal, whatever), get some user input, close the newly opened terminal and use the data that was input?

share|improve this question
up vote 4 down vote accepted

Consider using something like zenity instead.

QUEST="$(zenity --entry --title="Answer these questions three" --text="What is your quest?")"
share|improve this answer
Thanks ... zenity is nice! – Zardoz Nov 1 '10 at 2:05

Here's how you could do that using xterm:

mkfifo answer.fifo
xterm -T window-title-string -n icon-string -e bash -c 'read -p "input-prompt: " answer; echo "$answer" > answer.fifo' &

See man xterm for more information on controlling the size and position of the window and the color and font of the text if you'd like the appearance to be other than the default.

Doing it with gnome-terminal would be similar, but with fewer options for initially controlling window size, position and color (you could use tput in the -e script that you send it, though).

share|improve this answer
Thank you too ... another very fine solution. Even a bit more desktop environment independent. I stay with zenity as I always use Gnome/GTK. But good to know. – Zardoz Nov 1 '10 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .