Timsen
Timsen

Reputation: 4126

How to open terminal on run of .sh file in linux?

So i have my file run.sh :

#!/bin/bash
rails s
cd public/angular
grunt serve

Right now if i run sh run.sh i start rails server, but grunt serve is never fired. But the main problem i am strugling with is that i want to open a separate terminal window where rails s fires, and afterwards open second terminal windows where grunt serve is runned.

So it should look something like :

     #!/bin/bash
Open new terminal window ->
       run rails s in newly opened window
        cd public/angular
open second terminal window
       run grunt serve in second terminal window

Is it possible to do this in .sh file?

Upvotes: 0

Views: 2551

Answers (1)

d125q
d125q

Reputation: 1666

Would something like this work?

#!/bin/bash
xterm -e "rails s"
cd public/angular
xterm -e "grunt serve"

Replace xterm with your preferred terminal emulator (gnome-terminal, konsole, etc.).

Upvotes: 2

Related Questions