Removed /usr/local from CDPATH
[clearscm.git] / cc / lsnusers
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         $RCSfile: lsnusers,v $
5 # Revision:     $Revision: 1.3 $
6 # Description:  This script will perform builds for ILM/HP.
7 # Author:       Andrew@DeFaria.com
8 # Created:      Mon Feb 13 10:35:34 PST 2006
9 # Modified:     $Date: 2011/08/31 21:57:06 $
10 # Language:     Perl
11 #
12 # (c) Copyright 2006, Andrew@DeFaria.com, all rights reserved.
13 #
14 ################################################################################
15 use strict;
16 use warnings;
17
18 use FindBin;
19 use lib "$FindBin::Bin/../lib";
20
21 use Getopt::Long;
22
23 use OSDep;
24 use Display;
25 use Utils;
26
27 my $me = $FindBin::Script;
28
29 # Pick up from the environment if the user specifies pvob
30 my $pvob = $ENV{pvob};
31
32 my @pvob_related_objects = (
33   "activity",
34   "stream",
35 );
36
37 sub Usage {
38   my $msg = shift;
39
40   display "Usage: $me: <object_selector>";
41
42   if (defined $msg) {
43     error "$msg", 1;
44   } # if
45
46   exit 0;
47 } # Usage
48
49 Usage "Must specify an object selector" if !defined $ARGV [0];
50
51 my $object      = $ARGV [0];
52 my $object_type = $object;
53 my $full_object;
54
55 $object_type =~ s/:.*//;
56
57 if ($object =~ m/(.*)\@(.*)/) {
58   $object       = $1;
59   $pvob         = $2;
60 } # if
61
62 Usage "Must specify pvob or set pvob in your environment" if !$pvob;
63
64 if (InArray $object_type, @pvob_related_objects) {
65   # Need to add additional "\\" because Windows will eat them up when executing a ``;
66   if ($arch eq "windows" or $arch eq "cygwin") {
67     $full_object = "$object\@\\$pvob";
68   } else {
69     $full_object = "$object\@$pvob";
70   } # if
71 } else {
72   $full_object = $object;
73
74   # Handle oddity with windows using \ for vob tags
75   if ($full_object =~ /vob:\\(.*)/) {
76     $full_object = "vob:\\\\" . $1;
77   } # if
78 } # if
79
80 my $cmd = "cleartool lslock $full_object 2>&1";
81 my @output      = `$cmd`;
82 my $status      = $?;
83
84 if ($status eq 0) {
85   if (scalar @output eq 0) {
86     display "$object is not locked";
87     exit 0;
88   } # if
89 } else {
90   display "$object does not exist";
91   exit 1;
92 } # if
93
94 my @users;
95
96 foreach (@output) {
97   if (/\"Locked except for users: (.*)\"/) {
98     @users = split " ", $1;
99     last;
100   } # if
101 } # foreach
102
103 if ((scalar @users) gt 0) {
104   display "Users excluded from lock for this $object_type include:";
105
106   foreach (sort @users) {
107     display "\t$_";
108   } # foreach
109 } else {
110   display "This $object_type is locked from all users";
111 } # if