Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my script in init.d (Debian Linux)

#! /bin/sh
# /etc/init.d/blah

# Some things that run always
touch /var/lock/McMyAdmin

# Carry out specific functions when asked to by the system
case "$1" in
echo "Starting McMyAdmin "
screen -dmS Minecraft
sleep 2
screen -S Minecraft -X stuff "bash /opt/McMyAdmin/"`echo -ne '\015'`
echo "Stopping McMyAdmin"
screen -S Minecraft -X stuff "\quit"`echo -ne '\015'`
echo "Usage: /etc/init.d/McMyAdmin {start|stop}"
exit 1

exit 0

My problem is that upon starting the screen session, nothing happens. If I type line by line it works fine, but in the script nothing works. It creates the screen session but no commands are sent to it. what am I doing wrong?

share|improve this question

You have to cd to the McMyAdmin installation directory before you can run it. You can't run its script from another directory.


screen -S Minecraft -X stuff "bash /opt/McMyAdmin/"`echo -ne '\015'`


cd /opt/McMyAdmin/
screen -S Minecraft -X stuff "sh"`echo -ne '\015'`

Also it's not a brilliant idea to put McMyAdmin in /opt/ and running it as root. Instead you should create a user just for it and use either a @reboot line in that users crontab, or use su in your initscript to change which user is used to run the server.

share|improve this answer
That dosen't seem to do it. Its the weirdest thing. It seems like I cannot send a command to the screen inside the script. I cannot send anything. This would work fine outside the script. – Adam Schiavone Feb 15 '12 at 1:53

You must log in to answer this question.

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