2

I want to run a program from inside a bash script, such that it opens in a new command line window. How can I do this?

2 Answers 2

5

That really depends on the GUI you are using. Try some of the below for executing an ls command.

With gnome-terminal:

gnome-terminal -x bash -c "ls; bash"

(taken from http://www.linuxquestions.org/questions/programming-9/is-command-line-invocation-of-gnome-terminal-to-run-more-than-one-command-possible-789599/)

With xterm:

xterm -e "ls; bash"

(taken from http://ubuntuforums.org/showthread.php?t=760006).

For konsole, take a look here:

or here:

Sign up to request clarification or add additional context in comments.

2 Comments

should I add terminal checks like "if [$TERM = "xterm"];then" in that case?
This will not work - e.g. I have TERM=xterm, but xterm is an unknown command, gnome-terminal is a right one in my case. You can do something like: gnome-terminal -x bash -c "ls; bash" || xterm -e "ls; bash" to first rune gnome-terminal and xterm only if it fails (note it will output "command not found") or use some more complex detection. If on one system, I wouldn't worry about that.
0

xterm -e 'program to be run'

Your terminal may have a different switch than -e, but I don't know what your terminal is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.