#!/bin/bash # Author Sid # Date 14/07/08 s='' #while [ -f '/root/.vnc/FLY:'$1'.pid' ]; do for i in `ls /root/.vnc/FLY:*.pid 2> /dev/null`; do i=${i: 0: ${#i}-4} # removed the .pid extension num=${i:15} # the number of this instance timestamp=`head -n1 $i.log | awk '{print $2}'` s+=$num" :: started "$timestamp"\n" done if [ ${#s} -gt 0 ]; then echo -e "Which of the following instances of vncserver would you like to kill?" echo -e "0 :: All" echo -e $s echo -e "Enter a number between 0 and $num and hit [ENTER]" read tokill if [ "$tokill" -eq 0 ]; then kill `cat /root/.vnc/FLY:*.pid` rm /root/.vnc/FLY:* echo -e "Killed" elif [ -f /root/.vnc/FLY:$tokill.pid ]; then vncserver -kill :$tokill echo -e "Killed" else echo "*sigh* Try again" fi else echo -e "There was nothing to kill" fi