Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 387
user1621988 Avatar asked Dec 11 '12 22:12

user1621988


1 Answers

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.)

like image 103
kvaale Avatar answered Nov 04 '22 02:11

kvaale