user1621988
user1621988

Reputation: 4335

Shell GNU-Screen -X Stuff problems

OPTIONS="java -Xms1024M -Xmx1024M -jar craftbukkit.jar"
PROCESS=server01

screen -dmS $PROCESS $OPTIONS nogui             # Starting the application
screen -x $PROCESS -X stuff `printf "stop\r"`   # Closing the application
screen -x $PROCESS                              # Attaching to the terminal of the application

The application works fine at the start, however I get problems with stuff 'printf "stop/r"' It seems not to work when I just start up, wait some time and then try to stop it with the command above. But the strange thing is, that if I did screen -x $PROCESS and detach (ctrl-A & ctrl-D) and then I use the Stop command it does work. So is there a way around to stuff printf without screen -x $PROCESS?

Upvotes: 8

Views: 4629

Answers (1)

kvaale
kvaale

Reputation: 644

Adding the argument -p 0 should fix it. Something like this:

screen -x $PROCESS -p 0 -X stuff `printf "stop\r"`

(From screen documentation: -p window Preselect the named window if it exists.)

Upvotes: 18

Related Questions