Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Solved!

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

screen -x 1234 -X -p0 stuff $'hello world\n'
share|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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .