I've been trying to set up an automated backup system for a minecraft server, and I'm having trouble with screen, specifically when using 'screen -r sessionname -X "/var/minecraft/somebatchfile"', nothing happens.
My process flow is somewhat like this at the moment:
screen -m -d -S minecraft /var/minecraft/bin/server_nogui.sh
This starts the minecraft server without any trouble. However, the issue is that even simple followups like this fail:
screen -r minecraft -X "stop"
I get no error message or success message, and the server does not actually disconnect clients and shut down, like it should. I assume I'm doing something wrong, but I don't know what. Is there some obvious mistake I'm making? I've read the man page a bit but I'm having no luck figuring it out myself.
ssh -t -i ~/.ssh/id_dsa server_user@server_address screen -r minecraft -X stuff "even other_server_name is getting in on the action! $(echo -ne '\r')"
I'm really not good with unix, unfortunately :/ – Sukasa Jan 14 '11 at 10:39printf
to inject the newline char is perfect. I don't know if it's an idiosyncrasy ofzsh
, but I could not get any of my old snippets (which used^M
as newline) to work in the current version of macOS. – stephancasas Jun 05 '22 at 17:00