Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a little problem with screen.

I wanted to launch several servers in a screen session, so I made a little script designed to to have one server per window.

#!/bin/sh
screen -dmS servers
screen -S servers -t http -p 0 sh -c "cd /servers/start/httpo ; run.sh"
screen -S servers -t sql -p 1 sh -c "cd /servers/start/sql ; run.sh"
...

But it's not working right - the sessions are created, but all the commands start on the first window.

I read the man page, but I still can't find what I did wrong.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Try this:

#!/bin/bash

screen -dmS servers -T xterm -t "http" sh -c 'cd /servers/start/httpo;run.sh'

screen -T xterm -S "servers" -X screen screen -t "sql" sh -c 'cd /servers/start/sql;run.sh'
...

The "-T xterm" switch isn't really necessary, unless you plan to use curses-based programs from inside the screen (mc, less, etc.).

share|improve this answer

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.