[comp.os.vms] number of users logged in

ERIC@UOFT02.BITNET.UUCP (06/03/87)

This simple program counts the number of processes logged in.  If you have
neither world nor group privs,  then it returns the number of processes in
your account.  If you have group privs, it returns the number of processes
in your group, and if you have world privs,  it returns the number for the
whole system. Since I do not have world or group privs during execution of
my login.com file (they are not set as default privs for my account) I use
this routine in my login.com to see if any other processes are logged into
my account.  If you have world/group privs, you can always drop them, then
run this routine, then regain them...  If you don't want a real fancy type
of display, then just use:  SHOW USER 'F$GETJPI(0,"USERNAME")

Eric Rostetter

Eric @ UOFT02.bitnet

--------------

$ set noverify
$ count = -1
$ context = ""
$ loop:
$   pid = f$pid(context)
$   if pid .eqs. "" then goto finis
$   count = count + 1
$   goto loop
$ finis:
$ are_is ="are"
$ user_s = "s"
$ if count .eq. 1 then are_is ="is"
$ if count .eq. 1 then user_s = ""
$ write sys$output "There ''are_is' ''count' other user''user_s' in " -
  + "this account"
$ exit