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.

The .screenrc file allows the user to specify that they want multiple windows open when screen is first run. Eg.

screen -t myWindowA 0 "" 
screen -t myWindowB 1 "-${SHELL}" 
screen -t myWindowC 2 "-${SHELL}"

What I would like is for each window to run some commands first, like:

screen -t myWindowA 0 "<go to directory a, source a.sh" 
screen -t myWindowB 1 "-${SHELL} <go to directory b, source b.sh>" 
screen -t myWindowC 2 "-${SHELL} <go to directoy c; start a watch on `ls -l`>"

Is there any way to do that?

Note this is similar to, but different from this issue.

share|improve this question
1  
It's a tiny bit off topic, but have you heard of byobu? It's screen, but a bit easier to use. If so, nevermind. :) If not: help.ubuntu.com/10.04/serverguide/C/byobu.html –  Stefano Palazzo Nov 8 '10 at 16:03

1 Answer 1

up vote 2 down vote accepted

Sure you can. On my servers i have a /etc/screenrc with:

screen -t TOP 0 top
screen -t ETC 1 cd /etc
screen -t Console 2
share|improve this answer
    
the first example works great, but I can't seem to get it to work with sourced environments, eg "source env.sh". I get "Cannot exec 'source': No such file or directory" then "[screen is terminating]". When I try to "cd" as in your second example, I get the a similar error. –  Robert Gowland Nov 8 '10 at 19:58
1  
@Robert Gowland source is a bash builtin, so it can't be executed by scree... Your best option, IMHO, is to create some bash scripts and execute them instead. –  Mr Shunz Nov 9 '10 at 10:37
    
cool. Thanks for helping me understand what will and won't work. –  Robert Gowland Nov 9 '10 at 14:13

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.