2

I run a simple minecraft server. I made a script awhile ago for Ubuntu that would automatically create a Gnu screen and start said server. I decided get a new server with Debian instead. Now for some reason, the script will not work and I have no idea why!

sleep 5
screen -dmS mc
sleep 1
screen -p 0 -S mc -X stuff "cd /home/server/Desktop/ServerSoftware/Minecraft/modpacks^AgrarianSkiesHQ^3_1_1^AgrarianSkiesHQServer"
sleep 1
screen -p 0 -S mc -X eval "stuff \015"
sleep 1
screen -p 0 -S mc -X stuff ./ServerStart.sh
sleep 1
screen -p 0 -S mc -X eval "stuff \015"

How it's supposed to work:

  1. Start a minimized GNU-Screen
  2. Change Directory to the minecraft server directory
  3. Start the server

Basically how it doesn't work is that it WILL create the screen and be detached from it. But after that, when I resume the screen I have to CTRL+c to be able to input anything. the "cd" command never gets sent through, nor the ./StartServer.sh

The "^" in the CD line are supposed to be there. I have tested the command in terminal and it works as wanted.

6
  • 3
    Are those ^A on propose?
    – Braiam
    Jul 11, 2014 at 21:08
  • In the change directory command? yeah. its how the file unzipped and testing the command in normal terminal allowed me to change directory to that folder. Jul 11, 2014 at 21:45
  • Did you check the version numbers of screen on the different machines? Or your shell?
    – MadTux
    Jul 11, 2014 at 22:32
  • What is the contents of ~/.screenrc on both machines? Jul 12, 2014 at 19:30
  • @MadTux I no longer have access to the old machine. It was a VPS I rented awhile ago. Jul 12, 2014 at 20:13

1 Answer 1

3

Your script doesn't work because ^ introduces a control character sequence. The two-character ^A stuffs a Ctrl+A character, which bash interprets as the command to go to the beginning of the line. You need to use \^ instead.

screen -p 0 -S mc -X stuff 'cd /home/server/Desktop/ServerSoftware/Minecraft/modpacks\^AgrarianSkiesHQ\^3_1_1\^AgrarianSkiesHQServer^M'
screen -p 0 -S mc -X stuff './ServerStart.sh^M'

I can't find any record in the Screen changelog showing that this behavior changed, but if your script worked on an older machine, it must have.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .