2 ################################################################################
4 # File: $RCSfile: mknusers,v $
5 # Revision: $Revision: 1.3 $
6 # Description: This script will add a user to the nusers list for a lock
7 # Author: Andrew@DeFaria.com
8 # Created: Mon Feb 13 10:35:34 PST 2006
9 # Modified: $Date: 2011/08/31 21:57:06 $
12 # (c) Copyright 2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
19 use lib "$FindBin::Bin/../lib";
27 my $me = $FindBin::Script;
29 # Pick up from the environment if the user specifies pvob
30 my $pvob = $ENV{pvob};
32 my @pvob_related_objects = (
40 display "Usage: $me: <object_selector> <username> [<username>]";
54 my $cmd = "cleartool lock -replace -nusers ";
60 $cmd .= "$username $object";
70 Usage "Must specify an object selector" if !defined $object;
71 Usage "Must specify an username" if scalar @users eq 0;
73 my $object_type = $object;
76 $object_type =~ s/:.*//;
78 if ($object =~ m/(.*)\@(.*)/) {
83 Usage "Must specify pvob or set pvob in your environment" if !$pvob;
85 if (InArray $object_type, @pvob_related_objects) {
86 # Need to add additional "\\" because Windows will eat them up when executing a ``;
87 if ($arch eq "windows" or $arch eq "cygwin") {
88 $full_object = "$object\@\\$pvob";
90 $full_object = "$object\@$pvob";
93 $full_object = $object;
95 # Handle oddity with windows using \ for vob tags
96 if ($full_object =~ /vob:\\(.*)/) {
97 $full_object = "vob:\\\\" . $1;
102 my $cmd = "cleartool lslock $full_object 2>&1";
107 display "$object does not exist";
114 if (/\"Locked except for users: (.*)\"/) {
115 @current_users = split " ", $1;
120 if (InArray $_, @current_users) {
121 error "User $_ is already on the nusers list for $object", 1;
123 if (AddNuser $full_object, $_, @current_users) {
124 error "Unable to add $_ to nusers list for $object", 2;
126 display "User $_ added to the list of nusers for $object";