简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM