Screen supports externally controlling a detached screen with the -X parameter, for example:

screen # -X -p0 "quit"

That will terminate the screen where # is the screen PID. However what I want to do is pass a command "inside" the screen. So for example if the program inside is nano and I want to write "hello world" into that nano process how would I do it via screen?

 screen # -X -p0 "hello world"

That treats it as if I want the screen to run "hello world" (which isn't a command) but I want to pass it to the program running inside screen.

I can't find any information in the manual. I'm running centos.

link|improve this question
feedback

1 Answer

Solved!

For anyone reading this via google the answer is pretty simple: Stuff.

screen -x 1234 -X -p0 stuff $'hello world\n'
link|improve this answer
+1. Note that $'' is for your shell (likely bash) to interpret the \n as a newline. – Roger Pate Jun 21 '10 at 2:33
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.