IBM Support

How to find the number of active Clearquest users using a script

Question & Answer


How do you find the count of active users in IBM Rational ClearQuest?


Using a script to count ClearQuest Active users at any point of time to provide a quick solution for Admin/Management to maintain correct metrics/Stats.


The following script will count the Active ClearQuest users at any point of time and will print the output to the command line.

Note: This script is applicable on Windows platform and ClearQuest must be installed on the machine where the script is running.


  1. Open a command prompt and run the following command to see if CQperl is installed:

    cqperl -v

    Note: It should return the Perl version installed on the machine. If this command does not give the output of Perl version, change directory (cd) in the command window to set to the correct path where cqpearl.exe resides.

    For example: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Create a text file which contains your Schema Repository Login information.


    For # example- connection_info.txt
    This text file should contain the below 3 lines-
    dbset:<Schema Repository Name>
    user:<Admin user>
    passwd:<Admin password>

  3. Save the following script text to notepad with a .pl extension and the run the script using the following command:

    cqperl <>

    Note: You should have both "perl" file and "Text" file in the same directory. If not, modify the path in the script accordingly.


All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


#!C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

#Identify the correct location of your CQperl.exe file and give the path above

use CQPerlExt;

#Provide the text file location containing Schema login information in the below format-
#dbset:CQ Schema Repository Name
#passwd:Admin password

#You should have both "perl" file and "Text" file in the same directory. If not, please modify the below
# path accordingly.
#Fetching the Schema Repository details from the file and putting them into respective variables.

my $file = './connection_info.txt';

open (FILE, $file) || die "Error: $!\n";
while (<FILE>) {
if ($_ =~ m/dbset:(\S+)/) {
$d = $1;
if ($_ =~ m/user:(\S+)/) {
$u = $1;
if ($_ =~ m/passwd:(\S+)/) {
$p = $1;
close (FILE);

my $dbset = $d;
my $adminUser = $u;
my $adminPasswd = $p;

#Create a Rational ClearQuest admin session
$adminSession= CQAdminSession::Build();
#Logon as admin
$adminSession->Logon( "$u", "$p", "$d" );

#Get the list of users in the repository.

$userList = $adminSession->GetUsers();

 #Get the number of users

$numUsers = $userList->Count();
#Iterate through the users

print "Total Number of users = $numUsers\n";
$numActiveusers = 0;

#Rinning a loop to check each user if Active or not.
for ( $x=0; $x<$numUsers; $x++ )
#Get the specified item in the collection of users
$userObj = $userList->Item( $x );
$usercnt = $userObj->GetActive();
# print "User status is = $usercnt\n";
if ($usercnt)
$numActiveusers = $numActiveusers + 1;
print "Number of Active Users = $numActiveusers\n";

#Unbuild the Admin session

[{"Product":{"code":"SSSH5A","label":"Rational ClearQuest"},"Business Unit":{"code":"BU004","label":"Hybrid Cloud"},"Component":"User Administration","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.0.1;7.1;7.1.2;;8.0","Edition":""}]

Document Information

Modified date:
16 June 2018