views:

223

answers:

1

I asked a similar question here and got pretty close to what I'm looking for

http://stackoverflow.com/questions/1220797/how-to-start-a-process-from-another-application-and-then-open-a-terminal-to-that

...but, this doesn't quite get to what I'm after, which is starting a process in a new window (not an existing window) in an existing screen session (not a new screen session).

If you are at a command prompt in a screen session, you can do this:

screen [screen options] command param1 param2

But, how do you do it if you are outside the session? For example, if you want to run this as a cronjob?

+1  A: 

When you aren't in a screen session, you can pass the -X flag to screen to execute a screen command.

For example, the screen command in screen opens a new window, optionally with a command to execute.

Assuming you already have screen open somewhere:

screen -dr -X screen sleep 20

Note that the new window will close once the command (sleep in this case) finishes. If you want to keep it open you could potentially do something like this, which will type 'date\n' in the new window:

screen -dr -X screen
screen -dr -X stuff "date
"

The man pages of course have much more detail.

alberge

related questions