#!/usr/bin/perl ################################################################################ # # File: $RCSfile: lsnusers,v $ # Revision: $Revision: 1.3 $ # Description: This script will perform builds for ILM/HP. # Author: Andrew@DeFaria.com # Created: Mon Feb 13 10:35:34 PST 2006 # Modified: $Date: 2011/08/31 21:57:06 $ # Language: Perl # # (c) Copyright 2006, Andrew@DeFaria.com, all rights reserved. # ################################################################################ use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; use Getopt::Long; use OSDep; use Display; use Utils; my $me = $FindBin::Script; # Pick up from the environment if the user specifies pvob my $pvob = $ENV{pvob}; my @pvob_related_objects = ( "activity", "stream", ); sub Usage { my $msg = shift; display "Usage: $me: "; if (defined $msg) { error "$msg", 1; } # if exit 0; } # Usage Usage "Must specify an object selector" if !defined $ARGV [0]; my $object = $ARGV [0]; my $object_type = $object; my $full_object; $object_type =~ s/:.*//; if ($object =~ m/(.*)\@(.*)/) { $object = $1; $pvob = $2; } # if Usage "Must specify pvob or set pvob in your environment" if !$pvob; if (InArray $object_type, @pvob_related_objects) { # Need to add additional "\\" because Windows will eat them up when executing a ``; if ($arch eq "windows" or $arch eq "cygwin") { $full_object = "$object\@\\$pvob"; } else { $full_object = "$object\@$pvob"; } # if } else { $full_object = $object; # Handle oddity with windows using \ for vob tags if ($full_object =~ /vob:\\(.*)/) { $full_object = "vob:\\\\" . $1; } # if } # if my $cmd = "cleartool lslock $full_object 2>&1"; my @output = `$cmd`; my $status = $?; if ($status eq 0) { if (scalar @output eq 0) { display "$object is not locked"; exit 0; } # if } else { display "$object does not exist"; exit 1; } # if my @users; foreach (@output) { if (/\"Locked except for users: (.*)\"/) { @users = split " ", $1; last; } # if } # foreach if ((scalar @users) gt 0) { display "Users excluded from lock for this $object_type include:"; foreach (sort @users) { display "\t$_"; } # foreach } else { display "This $object_type is locked from all users"; } # if