3

I'm trying to open gnome-terminal (though I think it would be related to any x-terminal-emulator) with a command provided using -e option, like gnome-terminal -e 'ls'. The terminal is closed as soon as the command is done working, so I need a way to wait for user input to be able to read the result and then finally close the window with Enter press.

I tried gnome-terminal -e 'ls; read -p "..."' and it works if I run ls; read -p "..." in an already opened terminal, but a terminal called with -e option keeps getting closed.

So is there any way to keep the terminal open until some user input is provided while using -e option?

gvlasov
  • 18,638
  • 21
  • 74
  • 110
  • I think this is a duplicate question. [Prevent Gnome Terminal From Exiting After Execution](http://stackoverflow.com/questions/4465930/prevent-gnome-terminal-from-exiting-after-execution) and possibly this [Avoid gnome-terminal close after script execution?](http://stackoverflow.com/questions/3512055/avoid-gnome-terminal-close-after-script-execution) – Robert Gomez May 07 '13 at 05:54

1 Answers1

6

Spawn a shell;

xterm -e bash -c 'ls; read -p "Press any key ..."'
tripleee
  • 175,061
  • 34
  • 275
  • 318