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 need to start multiple apps running in shells and monitor their execution. Currently I have a main script that launches every apps in a new gnome-console but I would prefer to launch them all in the same window in split screens.

This post Multiple shells in one window explains how to use split screens with many type of console applications such as screen, terminator and byobu. This works fine manually but I would like to be able to start all my apps in a split screen console automatically from my main scrip. In the documentation from the tools mentioned above there was nothing I could fine to achieve this automatically from a script.

Any ideas?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can make a custom screen config file that will open up multiple splits and launch your scripts in them. It would look something like this:

screen script1.sh # Open first screen and launch first script
split             # Make second split
focus             # Switch to second split
screen script2.sh # Open second screen and launch second script
split             # Make third split
focus             # Switch to third split
screen script3.sh # Open third screen and launch third script

Put this in a file called myscripts and launch screen with screen -c myscripts. If you prefer vertical splits, just add -v to the split commands.

If you'd like a grid layout, try something like this:

screen script1.sh # Open first screen and launch first script
split -v          # Make second split
focus             # Switch to second split
screen script2.sh # Open second screen and launch second script
split             # Make third split
focus             # Switch to third split
screen script3.sh # Open third screen and launch third script
focus             # Cycle back to first split
split             # Split first split horizontally
focus             # Switch to new split
screen script4.sh # Open fourth screen and launch fourth script
share|improve this answer
    
Thanks a lot this worked like a charm. The only other issue is that after starting my multiple scripts, I can C-a C-d to return to my terminal but when I do "screen -r" it resumes to my last open tab and I cannot see the output of the other tabs anymore. "screen -ls" shows only one instance but I can see that all my scripts are still running in the process list with "ps". So how can I detach my multi-tab screen and go back to it with the same state? –  jmbouffard Jun 21 '11 at 15:22
    
I found a superuser question about that: superuser.com/questions/69816/… Looks like a thorny problem. It occurs to me that you might also be able to make a macro that reestablishes your splits. –  Ben Williams Jun 21 '11 at 20:01
    
The tip from the superuser forum doesn't seems to work for me because the nested session doesn't seem to use my configuration when I launch it with the -c option. –  jmbouffard Jun 23 '11 at 18:52
    
I also tried your other idea to reestablish my splits with a config file such as the one shown in your answer. But I guess I need to use "screen -r -c macro" but it seems I cannot combine the -r option with -c because it doesn't take my commands into account. "-c" alone re-establishes my splits with empty screens, "-r -c macro" does the exact same thing as "-r" alone and does not create any split. –  jmbouffard Jun 23 '11 at 18:57
add comment

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.