Hello I am running Ubuntu 10.04 and learning the ROS (Robot Operating System) which means that I enter quite a lot of shell commands

I am currently creating some BASH script files to make my work easier, but there are certain commands which must be run in another console.

So please tell me what commands I must write in my .sh file so that it can run it's commands in one window,then start another window in which it run other commands, but from the same .sh file

Or they could be in different .sh files they just need to run in different consoles.

  • Can you describe what you are wanting exactly ? Potential solutions include screen to running gnome-terminal -e "command" to running a command in the background, with nohup and the & nohup command & – Panther Dec 17 '11 at 15:27
  • For example I need to run the command 'rosrun turtlesim turtlesim_node' in a new console then I need to run other commands in other new consoles. And I would like to do this from a single .sh file. – Bora George Dec 17 '11 at 15:35
  • Also I forgot to add these commands should not run in the background. – Bora George Dec 17 '11 at 15:42

You could run your script in another terminal emulator window, I suppose gnome-terminal with the command

gnome-terminal -x ./script

You could simplify the process defining a function in your ~/.bashrc

start() {
  gnome-terminal -x "$@"

where can choose the name you prefer instead of start. You use the function in this way

start ./command arg1 arg2

(you need to restart the terminal for the shell to know about the new function).

As you can see, there is a little problem, the window closes once the command terminates. To avoid this you could wrap your command in a shell script and add a last line with a read command:

# script

./command arg1 arg2
read answer

Then when you call

start ./script

it will not closes, waiting for your input.

Unfortunately, It is difficult to automate this in the start function.

  • Thank you all the replies have been helpful but I've found out that ros commands have a problem with the gnome-terminal-x command. – Bora George Dec 17 '11 at 15:51
  • @BoraGeorge: I updated the answer to take into account the closing of the window. – enzotib Dec 17 '11 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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