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

I have a screen running a server. That screen is run with:

screen -m -d -S server (cmd to start server)

Then I want to send a command to the server by doing this:

screen -S minecraft -X stuff (cmd)

That sends the command to the server but doesn't execute it. (Like if you typed ls in the terminal without pressing enter).

So how can I excecute the command/simulate an enter press?

share|improve this question

You can do it by forcing a carriage return through.

One way to do that is to append a control-M character on the end. A typical way to do that on the shell is to hit ctrl-v first, and then press Return. The ctrl-v tells the shell that the next keypress is to be included literally. That prevents your Return from ending the line and issuing the command.

So your command would be something like:

screen -S minecraft -X stuff 'ls^M'

Where the ^M part is not literally those characters but in fact the result of pressing ctrl-v followed by Return.

share|improve this answer
OK, that was exactly what I was looking for. Thought it was something like that. – user156084 Sep 5 '12 at 17:25

You must log in to answer this question.