#!/bin/ksh ## ## SCRIPT NAME: rootwin_kill_bgpaste ## ## Where: in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: A utility to kill any 'bgpaste' processes running on 'this host' ## other than this 'bgpaste' script. ## ## This utility uses the 'ps -ef' command to find the 'bgpaste' ## PID or PID's and issues the 'kill ' command. ## ## A more elaborate 'kill processes' program, that allows for the user ## to review a list of PID's and select which ones to kill, is the script ## 'divviz_kill_pgms_bygui' in $FEDIR/scripts ############################################################################## ## INPUTS: none ## ############################################################################## ## CALLED BY: 'rootwin_tools' script in $FEDIR/scripts ## actually, by 'rootwin_tools.chestdef' in $FEDIR/scripts ## ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 13may2004 Based on 'divviz_sho_pids_bygui', ## and 'runcmd_on_pingable_hosts_bygui' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 13may2004 ############################################################################## if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi ################################################ ## GET THE 'ps -ef' INFO for 'bgpaste' processes, ## other than this script. ################################################ BASENAME_THISSCR=`basename $0` ############### ## FOR TESTING: (in place of the BGPASTE_PSINFO= lines below) ############### # BGPASTE_PSINFO=`ps -ef | grep bgpaste | grep -v grep` BGPASTE_PSINFO=`ps -ef | grep bgpaste | \ grep -v grep | grep -v $BASENAME_THISSCR` ################################################ ## GET THE PID's for 'bgpaste' processes, ################################################ BGPASTE_PIDS=`echo "$BGPASTE_PSINFO" | awk '{print $2}'` ################################################ ## Remove line-feeds, if any, from list of PIDs. ################################################ BGPASTE_PIDS=`echo $BGPASTE_PIDS` ###################################################### ## GET THE PPID's for 'bgpaste' processes. (not used) ###################################################### # BGPASTE_PPIDS=`echo "$BGPASTE_PSINFO" | awk '{print $3}'` ###################################################### ## FOR TESTING: (comment this out for production) ###################################################### # echo " # BGPASTE_PSINFO: # $BGPASTE_PSINFO # # BGPASTE_PIDS: # $BGPASTE_PIDS # " # # exit ################################################ ## SETUP THE 'confirm.tk' GUI -- to show the ## 'bgpaste' processes and to prompt for ## 'kill' or 'nokill'. ################################################ CONFIRM_TITLE="bgpaste-kill utility" export CONFIRM_TITLE CONFIRM_TEXT="\ The 'bgpaste' process(es) found, if any, is (are): $BGPASTE_PSINFO Click 'kill' to kill ALL the processes : $BGPASTE_PIDS --- or CLICK 'nokill' TO SIMPLY EXIT." export CONFIRM_TEXT # CONFIRM_GEOM="+080+080" CONFIRM_GEOM="700x300+080+080" CONFIRM_MINSIZE="150 100" export CONFIRM_MINSIZE CONFIRM_GEOM CONFIRM_COLOR="#3DADFF" export CONFIRM_COLOR CONFIRM_FONT="-adobe-helvetica-bold-r-normal--*-100-*-*-p-*-*-*" export CONFIRM_FONT ################################################ ## POPUP THE 'confirm.tk' GUI -- and do the kill ## if the user so specifies. ################################################ ## FOR TESTING: # set -x # KILL_YN=`$FEDIR/tkGUIs/confirm.tk kill nokill` KILL_YN=`$FEDIR/tkGUIs/confirm_scroll.tk kill nokill` if test "$KILL_YN" = "kill" then kill $BGPASTE_PIDS fi