#!/usr/bin/ksh clear ECHO=print function main_affirm { typeset answer typeset question=$1 typeset default=$2 case "${default}" in [yY]*) question="${question} ([y]/n)" ;; [nN]*) question="${question} (y/[n])" ;; *) question="${question} (y/n)" esac while : do ${ECHO} read -r "answer?${question} ? " || return 1 case ${answer} in [yY]*) listing if [ "$?" = "0" ] then list_com_conf del_affirm " Identify The Process Id's to be Killed and Press (Y) to Continue Or (N) to exit" "n" else list_incom_conf fi return 0 ;; [nN]*) return 1 ;; "") case "${default}" in [yY]*) listing if [ "$?" = "0" ] then list_com_conf del_affirm " Continue Killing" "n" else list_incom_conf fi return 0 ;; [nN]*) return 1 ;; esac ;; esac ${ECHO} '\n\t\t\a Enter "y" or "n" ' done } function del_affirm { typeset answer typeset question=$1 typeset default=$2 case "${default}" in [yY]*) question="${question} ([y]/n)" ;; [nN]*) question="${question} (y/[n])" ;; *) question="${question} (y/n)" esac while : do ${ECHO} read -r "answer?${question} ? " || return 1 case ${answer} in [yY]*) delete return 0 ;; [nN]*) ${ECHO} "\n\t\t----- Process Killing Incomplete -----\n " return 1 ;; "") case "${default}" in [yY]*) delete return 0 ;; [nN]*) ${ECHO} "\n\t\t----- Process Killing Incomplete -----\n " return 1 ;; esac ;; esac ${ECHO} '\n\t\t\a Enter "y" or "n" ' done } function kill_affirm { typeset answer typeset question=$1 typeset default=$2 case "${default}" in [yY]*) question="${question} ([y]/n)" ;; [nN]*) question="${question} (y/[n])" ;; *) question="${question} (y/n)" esac while : do ${ECHO} read -r "answer?${question} ? " || return 1 case ${answer} in [yY]*) ftptbakill ${ECHO} "\n\t\t----- Process Killing Complete -----\n " return 0 ;; [nN]*) ${ECHO} "\n\t\t----- Process Killing Incomplete -----\n " return 1 ;; "") case "${default}" in [yY]*) ftptbakill ${ECHO} "\n\t\t----- Process Killing Complete -----\n " return 0 ;; [nN]*) ${ECHO} "\n\t\t----- Process Killing Incomplete -----\n " return 1 ;; esac ;; esac ${ECHO} '\n\t\t\a Enter "y" or "n" ' done } function listing { ${ECHO} "\n\t " ${ECHO} "\n\t\t Process Listing of Ftp, Tbaadm, Sudodb and SdcEod Users..... " ${ECHO} "\n\t " ps -fu tbaadm,ftp,sudodb,sdceod | grep -v UID | tee ftptbaps.log cat ftptbaps.log | awk '{print $2}' > ftpsurekill.log } function delete { echo "\nFtp, Tbaadm, Sudodb and SDCEOD Process Kill Operation On: [`date +%d-%h-%Y==%H:%M:%S`]" >> ftptbakill.log cat ftptbaps.log >> ftptbakill.log ${ECHO} "\n\t " ${ECHO} "\n\t Enter Process For Killing. If There Are More Than One" ${ECHO} "\t Process, Then Separate Them With Spaces. \n\t" ${ECHO} "\t Without Any Process Id Don't Press Enter Key. \n\t" read ftpproc ${ECHO} $ftpproc > ftpproc ${ECHO} "\n\t The Process(es) Are : $ftpproc \n\t" for i in `cat ftpproc` do grep -w "$i" /users/sudodc/ftpsurekill.log 1>/dev/null 2>/dev/null if [ "$?" -ne "0" ] then ${ECHO} "\t CAUTION: Please See That Only FTP, TBAADM, SUDODB & SDCEOD Process Are Present !!!! \n" | tee -a ftptbakill.log exit 0 fi done ${ECHO} "\n\t Are U Sure? Do U Want To Kill These Process(es) !!!\n" ps -efp "$ftpproc" | grep -v "TIME" kill_affirm " Continue Killing" "n" } function ftptbakill { sudo kill -9 `cat ftpproc` 1>>ftptbakill.log 2>>ftptbakill.log } function list_com_conf { ${ECHO} "\n\t " ${ECHO} "\n\t\t PS Process Listing Complete. " ${ECHO} "\n\t " } function list_incom_conf { ${ECHO} "\n\t " ${ECHO} "\n\t\t\t No FTP, TBAADM, SUDODB & SDCEOD Process !!!. " ${ECHO} "\n\t " } function do_introduction { ${ECHO} ${ECHO} ${ECHO} "\n\n\t PROCESS LIST INFORMATION" ${ECHO} "\t ------------------------" ${ECHO} ${ECHO} ${ECHO} "\t Here List of Process Will Display for the Specific User Ids." ${ECHO} "\t " ${ECHO} "\t [ Press , the default answer is assumed. ]\n" main_affirm " Continue" "y" return } if do_introduction then :; else exit 0 fi