[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Counting interactive sessions?

» close window

The Question is:

 
How can I get how many interactive session a username has ?
 
I looked the lexical functions and I didn't find anything.
 
Thanks,
Ginette C. Fournier
(450) 928-5125 x 5255
 
 
 


The Answer is :

 
  This depends on what you mean by "Interactive". The DCL command
  SHOW USERS <username> will give you a count of all processes in INTERACTIVE
  mode, as defined by OpenVMS. However, this will include some processes which
  may not conform with all definitions of "interactive", for example,
  DECwindows sessions and subprocesses of interactive sessions. To be more
  specific, use the F$CONTEXT and F$PID lexical functions to select the
  processes you want. For example, the following will count all processes
  that are logged into a terminal:
 
 
$ IF p1.EQS."" THEN INQUIRE p1 "Username"
$ ctx = ""
$ temp = F$CONTEXT ("PROCESS", ctx, "USERNAME", p1,"EQL")
$ temp = F$CONTEXT ("PROCESS", ctx, "MODE","INTERACTIVE","EQL")
$ temp = F$CONTEXT ("PROCESS", ctx, "TERMINAL",-
		    "FT*,LT*,OP*,RT*,TN*,TT*,TX*,VT*","EQL")
$ count=-1
$ loop: count=count+1
$       IF F$PID(ctx).NES."" THEN GOTO loop
$ WRITE SYS$OUTPUT "Username ''p1' has ''count' interactive sessions"
$ EXIT
 
 
  (note the list of terminal names is not exhaustive, but includes the
  common terminal types).
 
  Additional calls to F$CONTEXT can be used to precisely specify the
  processes that you wish to count. See HELP LEX F$CONTEXT for more
  information.

answer written or last revised on ( 20-FEB-2001 )

» close window