Results 1 to 2 of 2
I run a game server for a game called Minecraft, and its all running through a Linux (CentOS 5.5) VPS. I have the server set up perfectly. I run hourly ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-27-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 1
Question About Screen Command
I run a game server for a game called Minecraft, and its all running through a Linux (CentOS 5.5) VPS. I have the server set up perfectly. I run hourly backups of the server map (you don't need to know what that is), and I use an executable shell file to do so. My current one is:
This sends the printf command to the (detached) screen that it's running in, and executes the command (for the game) called 'save-all'. That is working correctly. However, when I use the same command like so:Code:screen -x server -X stuff `printf "save-all\r"` sleep 2 cd server cd pandaland zip `date "+%Y-%m-%d-%H-%M-%S"`.zip -r ./* -x \*.zip
(The command for the server console here is 'say <message>', which outputs a message to all players in the server)Code:screen -x server -X stuff `printf "say testing\r"`
Nothing happens. I suspect that it is a problem with the spaces inside the command, but I can't get anything to work.
I then noticed that this code:
Actually prints the <command> (in this case, 'say testing') into the console, but doesn't execute it. It needs to send the enter key (what I assume here to be a newline key).Code:screen -x server -X stuff '<command>'
Anyone know what I should do?
- 04-04-2011 #2Linux User
- Join Date
- Nov 2008
- Location
- Tokyo, Japan
- Posts
- 258
Are you absolutely sure you need to output a "\r" and not a "\n", or perhaps both "\n\r"? The "echo" command does "\n" for you, so you don't need printf for that. You could also try this:
This does the same thing as the back-quotes, except it might handle cascading variables differently (I actually don't know) -- it is just something you can try.Code:screen -x server -X stuff $(printf "say testing\r")
Also, when using "printf", it is better to use single-quotes instead of double-quotes because single-quotes do not expand special characters.Check the bash manual for more information on the difference between single and double quotes.Code:screen -x server -X stuff $(printf 'say testing\r')


Reply With Quote
