Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am very new to linux platform.

Looking for a script file to call different application start up file located in different location and needs to be run in different terminals.

For example :

i have two .sh file like a.sh and b.sh in different locations.

Now need a script file to run these .sh file. when i run that script it should be open two terminals . In the first terminal a.sh should be called and b.sh file should be run on second terminal .

Thanks in advance for help.

Regards, Raghu

share|improve this question

1 Answer 1

That is quite simple. Write a script something like this:

#!/bin/bash
xterm -e /bin/bash /path/to/script_1.sh &
xterm -e /bin/bash /path/to/script_2.sh &

The -e option means "execute". The argument after it is the command to execute (here it is /bin/bash) and the next option is the argument for the command (here the name of the script-file). & means that the xterm-commands are running in background. If you remove the first &, it will run the first script completely and afterwards it will start the next command, but as I understood your question you want to run them simultaneously, so leave the & there.

You can also use the standard terminal instead of xterm, but this depends on the distribution and desktop you use. For example in gnome it would be gnome-terminal -x, but it should not make any difference when using xterm.

Hope this helps.

Greatings, Darth Ravage

share|improve this answer
    
I thought it was gnome-terminal -e (-x seems to work as well, but -e appears in the --help page)... Also, with gnome-terminal, you can get it to hold the terminal open (in preferences, under 'Title & Command'), so you can see the output when the scripts exits. Also, if the scripts being called have the shebang line #!/bin/bash, you shouldn't need to prefix the command /bin/bash (or bash) –  Wilf Jul 4 at 9:20
1  
You're perfectly right with the -e. My mistake. I wrote /bin/bash just for the sake of completeness, but as you said it is perfectly possible to just write bash. Thanks for the constructive criticism. –  Darth Ravage Jul 4 at 10:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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