Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.