Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 3 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
add comment

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' &
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.