2

As I am new to Linux and using ubuntu and I want help to write a script which will be having multiple commands and for each command a respective terminal should be opened and execute the command.

As I have written a script which having commands like:

mvn tomcat:run -Dmaven.tomcat.port=8081

mvn tomcat:run -Dmaven.tomcat.port=8181

So all these two command should be run in different terminal.

1 Answer 1

2

Depending on your Linux flavor there are a number of different terminals available, each of which has a potentially different mechanism for specifying a command.

However, it's pretty likely your Linux will have an xterm which will use a '-e' flag and take a command

e.g.

xterm -e "mvn tomcat:run -Dmaven.tomcat.port=8081"

For Ubuntu you can try

gnome-terminal -e "mvn tomcat:run -Dmaven.tomcat.port=808"
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks it works. Just for curiosity wanted to ask what is the command to open the default terminal of Ubuntu.
works but faced another problem, the new terminal doesn't hold it starts and closes immediately. Please help.
@Ravi xterm -e "mvn tomcat:run -Dmaven.tomcat.port=8081; read -p 'Command died. Press enter to close this terminal'"

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.