endofzero / Minecraft-Sheller

Shell script designed to allow for automation of Minecraft Server Administration.
62 stars 18 forks source link

PID finding is throwing a syntax error if Minecraft is not running when a PID check is ran. #17

Closed endofzero closed 13 years ago

endofzero commented 13 years ago
 ERROR: Process ID list syntax error.
 ********* simple selection *********  ********* selection by list *********
 -A all processes                      -C by command name
 -N negate selection                   -G by real group ID (supports names)
 -a all w/ tty except session leaders  -U by real user ID (supports names)
 -d all except session leaders         -g by session OR by effective group name
 -e all processes                      -p by process ID
 T  all processes on this terminal     -s processes in the sessions given
 a  all w/ tty, including other users  -t by tty
 g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
 r  only running processes             U  processes for specified users
 x  processes w/o controlling ttys     t  by tty
 *********** output format **********  *********** long options ***********
 -o,o user-defined  -f full            --Group --User --pid --cols --ppid
 -j,j job control   s  signal          --group --user --sid --rows --info
 -O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
 -l,l long          u  user-oriented   --sort --tty --forest --version
 -F   extra full    X  registers       --heading --no-heading --context
                     ********* misc options *********
 -V,V  show version      L  list format codes  f  ASCII art forest
 -m,m,-L,-T,H  threads   S  children in sum    -y change -l format
 -M,Z  security data     c  true command name  -c scheduling class
 -w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
 Minecraft server seems to be offline...

Maybe if we push the text into /dev/null as the error doesn't really seem to cause any issues other than just the display of the error. Really just any way to suppress that should work.

dopeghoti commented 13 years ago

What line is throwing the error? This could be handled pretty easily with code like:

RUNNING=$(kill -0 $PID)
if [ 0 -eq $RUNNING ]; then
    # We have a process at that PID
else
    # No such PID
fi
endofzero commented 13 years ago

Commenting out this line removed the error... so I'm guessing here...

    MC_PID=$(ps --ppid $SCREEN_PID -F -C java | tail -1 | awk '{print $2}')
endofzero commented 13 years ago

I output SCREEN_PID to see what is passed

No Sockets found in /var/run/screen/S-minecraft.

So maybe we just need to add a clause that states that if is says "No Sockets found*" or something like that, that the screen doesn't exist. From the looks of it... it is always passing a variable, which seems to always makes this false: if [[ -z $SCREEN_PID ]]; then

dopeghoti commented 13 years ago

This is fixed in my current pull request.

endofzero commented 13 years ago

I just tested the change and it is giving me the same results.

dopeghoti commented 13 years ago

Really? That's.. baffling. I tested it on BSD and Linux. When no screens are running, the variable is a null string, which [[ -z $SCREEN_PID ]] returns as true. What version of screen are you running? $screen --version Screen version 4.00.03jw4 (FAU) 2-May-06

dopeghoti commented 13 years ago

Ah, I think I found the difference- I'll make one more change and update the pull request.

endofzero commented 13 years ago

Alright... second time was the charm...