According to the docs for the Unix "screen" command, you can configure it in .screenrc to start with a bunch of default screens, each running a command that you specify.
Here's my cofig:
# Default screens
screen -t "shell_0" 1
screen -t "autotest" 2 cd ~/project/contactdb ; autotest
It will not run the autotest command. That window where I'm trying to run autotest
just closes instantly when I start screen
.
I also tried it with just...
screen -t "autotest" 2 cd ~/project/contactdb
Same result.
I also tried...
screen -t "autotest" 2 ls
Same result there too.
What's the secret to getting it to run a command in a given screen on startup?
You can also "stuff" characters into the screen as if you had typed them.
Here's how you can do that with your example:
Your program is being run (well, except the cd), it's just that it's being run without a parent shell, so as soon as it completes, it exits and you're done.
You could do:
Spawns two shells, but life will probably go on.
This might help but may not be entirely what you want.
Put "zombie az" or "defzombie az" as the first line of your .screenrc. "az" can be whatever 2 keys you'd like. Now, when a screen ought to close (command finished executing, for instance), it won't actually close; hitting 'a' will close it, hitting 'z' will re-execute the command attached to that screen.
I found that at the screen user's manual.
Here's how I'd do it.
The above appears to be evaluated procedurally by screen. First we establish a new screen with the title
shell_0
. Since we gave no other options, current working directory will be that of the parent shell or the user's home directory. We then set the default directory for new screens to~/project/contactdb
. Next, we establish a new screen running theautotest
command.Window number (
n
) is optional, I generally omit it.Try this:
Then later you can do:
Followed by:
Here's how mine looks. It seems to work fine. I think either the parenthesis might be causing the problem or screen will not open a window if the command "autotest" does not exist.