Run a command to screen to Minecraft server

Discussion in 'Server & Community Management' started by RiotShielder, Jul 11, 2013.

  1. I am wondering how I would send a command to my minecraft server that is ran through a screen session, basically I am working on a backup script and I need to use /save-off when the backup start and /save-on when it ends. I am unsure of how to run these commands through a screen session, any help will be appreciated.
     
  2. Do you name the screen session? When you start it, do something like:

    Code (Text):
    screen -dmS myScreen java blah blah blah
    Then to send (stuff) a command to it:
    Code (Text):
    screen -S myScreen -X eval 'stuff "save-all\015"'
    The \015 being the octal code for a 'carriage return'.
     
  3. Yes, I start it with a name, thanks for the help!
     
  4. Noob Question.

    How do I name the screen session?
     
  5. screen -S <name>
     
  6. You can start it in the background with a name using:

    Code (Text):
    screen -dmS <name> java blah blah blah
     
  7. How do I use that command?
    I do screen -s factions
    It then says "[Screen is terminating]"

    EDIT: Just got luke's post. Thanks.
     
  8. I don't know if I'm doing something wrong or not but this is what I'm doing. I currently use remote desktop which is why I'm a noob at ssh.
    this is what i do:

    screen -S hub java arguements
    I then let it load then do
    Ctrl A then Ctrl D to leave the screen session
    to resume the screen I try to do
    screen -r hub
    The error that it comes up with is "There is no screen to be resumed matching hub
     
  9. What happens when you do "screen -list"? Are you sure the server is still running?
     
  10. I did screen -ls earlier, not sure if it's the same as screen list. I'm on my phone right now so i can't Check. When i did screen -ls the screen was called something like 2012.hub
     
  11. Likely means that it's attached somewhere else, or the server went down.
     
  12. It said attached , what does that mean ? The server was not down
     
  13. when you connect to your server you can type screen -ls this lists your screens, you can then connect to the screen and close it if you want or just view console, but type screen -r 23134
    23134 is the example screen number you see when you type screen -ls.
    You can then close the screen while connected to it, this is useful cos i like to always connect to a screen before i close it to see what it is, by typing screen -r 23134.
    Once connected to a screen you can do command to either exit the screen or close the screen, to exit the screen(not close it) press CTRL A + D, to close the screen press CTRL C.
    I can never be bothered to name my screens, although i should as i find it easy to just connect to them. If you don't name your screen it will be a number like 23134
     
  14. It means that the screen had not been detached from wherever it was attached I think.
     
  15. Well I have no idea whats wrong.
    I named my screen test. I then left the screen.
    I then did screen -r test
    It then says:
    There is a screen on:
    22307.test (12/07/13 06:07:33) (Attached)
    There is no screen to be resumed matching test

    I tried doing screen -r 22307, screen -r 22307.test and test
     
  16. Basically, for whatever reason, you aren't detaching properly from the screen.

    Two options, force the screen to detach from wherever before attaching to you (this will kill the session of where the other screen is attached):
    Code (Text):
    screen -D -r test
    or ignoring the fact it is attached somewhere else and attach as well (multi-display mode):
    Code (Text):
    screen -x test
    The neater way (by tidying up ghost connections to screen session) is probably the first way. Personally, I use the second way when connecting because the 3 Co-Owners of the server all have access to ssh/the screen session, so it allows us to all see the screen at once :)