Good morning all,
I have a script that I wrote this morning that I can not figure out how to finish. This script will be used to kick a user out of my application. My goal is to prompt the user for the username of the person that they wish to kick off, retain that username in a variable, load in the userid associated with that username, and then use the userid to remove them from the system. My problem is, I want to propmt the user for the username, but the only way that I can kick someone out of the application is via the userid.
I am trying to take the following output:
UID user The rest is really useless information for this purpose ...
365 jx5h T00A1AD.opr.statefarm.org ECS_GUI 03/13/03 08:41:49:389920
447 jx5h T0093E5.opr.statefarm.org ECS_GUI 03/17/03 18:12:23:268080
450 c8zg T000FDA.opr.statefarm.org ECS_GUI 03/18/03 07:18:17:484342
retrieved with the following command:
ecs.ctl -U $euser -P $epass -C GUI_Server -M sf40ctm1 -cmdstr PGUI |grep -v Open |grep -v have |grep -v The
and feed the uid into the following command to remove them from the app:
ecs.ctl -U $euser -P $epass -C GUI_Server -M sf40ctm1 -cmdstr KICK $uid
Note: Currently I am printing some info to the user about the program, prompting
them for a username, and verifying that the username entered is currently logged
in to the application, and futher giving them only three attempts to enter a valid
username.
The following is what I have so far:
#!/usr/bin/ksh
logo="Remove ECS Users"
prmpt() {
clear
print "\n\t\t\t+----------------
----------
--+"
print "\t\t\t| ${logo} |"
print "\t\t\t|\t - $(hostname) -\t |"
print "\t\t\t+------------------
----------
+"
print "\n\n\n\n\n\tThis program will allow you to 'Kick' a user off of ECS."
print " Please do not kick a user off of ECS without notifying them first!"
print "\n\tEnter the the userid of the person to be removed below."
print "\t The userid will be the same as the SFID."
print "\nUserid -> \c"
read userid
}
pgui_out="/opt/incontrol/s
f_scripts/
admin/j8vy
/pgui_rpt.
txt"
euser=$(awk '{print $4}' /opt/incontrol/sf_scripts/
xfile)
epass=$(awk '{print $5}' /opt/incontrol/sf_scripts/
xfile)
set -A id $(ecs.ctl -U $euser -P $epass -C GUI_Server -M sf40ctm1 -cmdstr PGUI |grep -v The |grep -v have |grep -v Open |awk '{print $2}')
prmpt
cnt="-1"
while [[ ${userid} != ${id} ]]; do
if [[ ${cnt} < 2 ]] && [[ ${cnt} > "-1" ]]; then
print "\nOops ... That user is not currently logged in!"
print "Please enter a valid userid."
sleep 3
prmpt
elif [[ ${cnt} = 2 ]]; then
print "\nYou have reached the maximum number or retries!"
print "Please try again at a later time.\n"
exit 1
fi
let cnt+=1
done
Your thoughts are appreciated.
P.S. I would prefer to keep this in Korn Shell if it is possible. Thanks.