Sunday, January 11, 2009

Sending Commands to a Detached Screen Session

A quick note about sending commands to a detached screen session, good for using in start up scripts:

Example:

> screen -dmS [session name]
> screen -S [session name] -p 0 -X stuff [command^M]

where:
-d -m , means detach the session immediately, but fork off a new process, like a standard screen incarnation
-S sets a more human readable / sensible name for the screen session

-p 0 sets the targetted window within the screen session to be 0, neccessary if you haven't attached and detached from the session yet.

-X stuff sends the command to the nominated screen session. Not sure what the "stuff" part does.

0 comments: