Remote User Kill ...Remotely

This is a real yuck yuck. In previous threads I have explained how I need to kill a user without a user name. Without carrying all the baggage that goes with it, suffice it to say "I used to let the OS user be the Progress user, but now my app is using ODBC and as a result every other user is showing up blank.

Through the help of the "gurus", I am able to get the user id from the OS (Linux) so that the support people can kill hung sessions (they have this thing about knowing that Joey is really Joey when they isue the kill). It now works! Hooray!

However, There are a number of remote users that login through Windows. Sigh! Now I need to find a way to kill them as well. I built a Windows app to do this and it dawned on me "How can i kill a user from here?" Is there a gentle way to do this using the Progress Client or am I hosed? I suppose that I could find the PID on Windows and simply "End Process", but that would be less clean. Any ideas?

Thanks guys! You are the goods!
 
Windows application can disconnect users through appserver.
example.
FOR EACH _Connect NO-LOCK WHERE _Connect-Usr NE ?
AND
(_Connect-Type EQ "REMC" OR _Connect-Type EQ "SELF" or _Connect-Type EQ "0" )
BREAK BY _Connect-Usr:

IF _Connect-PID = ? THEN
NEXT.

IF _Connect-Type EQ "SELF" OR _Connect-Device NE "" THEN
ASSIGN cClientType = "4GL Client".
ELSE
ASSIGN cClientType = "SQL-92 Client".

FIND FIRST users WHERE users.sys-name = _Connect-Name NO-LOCK NO-ERROR.
IF AVAILABLE users THEN
DO:
user-name = users.Name.
rid-user = users.rid-user.
END.
ELSE
user-name = _Connect-Name.

CREATE work-users1.
ASSIGN
work-users1.logininfo = string (_Connect-time)
work-users1.tty-name = _Connect-Device
work-users1.user-name = user-name
work-users1.rid-user = rid-user
work-users1.pid = _Connect-PID
work-users1.id-proc = _Connect-Usr.
END.


RUN src/system/run_oscom.p ("sudo sh -c ""proshut ./db/account.db -C disconnect " + string (work-users1.id-proc) + """").

src/system/run_oscom.p
/* Run unix os-command on server */

DEFINE INPUT PARAMETER os-command-line AS CHARACTER.
DEFINE SHARED VARIABLE asbroker AS HANDLE NO-UNDO.
DEFINE VARIABLE use_appserv AS LOGICAL NO-UNDO.
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
DEFINE VARIABLE state AS LOGICAL NO-UNDO INITIAL TRUE.

IF SESSION:WINDOW-SYSTEM BEGINS "ms-win" THEN
DO:
IF NOT VALID-HANDLE (asbroker) THEN
CREATE SERVER asbroker.
use_appserv = false.
CASE asbroker:TYPE:
WHEN "SERVER" THEN
DO:
use_appserv = asbroker:CONNECTED ().
if not use_appserv then
do:
asbroker:CONNECT ("-pf appserv.pf") NO-ERROR.
use_appserv = asbroker:CONNECTED ().
end.
END.
END CASE.
IF use_appserv THEN
DO:
RUN src/system/exec_oscom.p /*PERSISTEN SET hProc*/
ON SERVER asbroker TRANSACTION DISTINCT (INPUT os-command-line).
END.
END.
ELSE
RUN src/system/exec_oscom.p (INPUT os-command-line).

src/system/exec_oscom.p
/* Execute user unix os-command */
DEFINE INPUT PARAMETER os-command-line AS CHARACTER.
OS-COMMAND VALUE (os-command-line).
 
If you use the KILL, the server will say ... I got system errors and to not loose data I have to stop.
then shutdown abnormaly. After this better to do a dump&load. The risque to crash the database with KILL is 9/10.
"proshut [db] -C disconnect" is a clean, no risque, option.
 
MaxMonin,
As to your use of the table "users". Do you mean _Users? If so, that info is not in there as there is only one user in the table for ODBC purposes. This leaves the remaining connections with a user-name that is blank.

user-name is what I am looking for here. On the Linux side, I can go out to the os and grep for the pid and awk the user-name from there. On remote sessions, the pid is from Windows, so that won't work. I am looking for how to do that on the Windows side. I think that the remote app is the way to go, if I can create a shared temp table with the user info (your work-users1). I may be daft, but I do not see how the Windows side of your code is going to give me the user-name. The support person who is going to be "disconnecting" the user will know only that user-name jrpuffnstuff needs to be disconnected. I have written a Windows program that provides them a list in pretty much the same way you have outlined in your code. I just need to populate the user-name to finish the job.

rstanciu,
the use of the word "kill" may have been too harsh. I am referring to disconnecting the user. I do conceed the "End Process" option is not the way to go.

Thanks to both of you!
 
usr pid time of login user id tty Limbo?
5 6931 Mon May 17 10:37:51 2010 APW /dev/pts/3 no
6 6934 Mon May 17 10:37:51 2010 BIW /dev/pts/3 no
7 6940 Mon May 17 10:37:51 2010 WDOG /dev/pts/3 no
9 6965 Mon May 17 10:38:01 2010 APW batch no
102 2348 Tue Jun 15 15:58:15 2010 dbadmin maximmonin no <- Windows Connection
Users - it is table in my DB. But if you have only 1 user i see following ways to indentify user:
1. _Connect._Connect-Device. it returns tty/pts on linux platform. It returns Windows Computer Name on windows platform.
2. _Connect._Connect-IPAddress. It returns Ip-address of windows connection.
 
Back
Top