#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -U #- # Copyright (C) 2002, Federal Linux Systems # License: GNU Lesser General Public License, v2.1 #- #- The -U flag is to allow running of the COE_get_user_id under -T mode #- The -w flag is dropped to prevent the above warning use strict; use Coe; my $PRGM="COE_get_user_data"; my $VERSION="1.1.4.0"; if (@ARGV == 0) { &useage; exit 202; } sub useage { print "Useage: $PRGM [options] "; print "{-f} {-n | -u } {-s a|g|l}\n"; } my $arg1; my $coedat; my $COEDAT; my $i; my $s="a"; my $scope="a"; my $userid="all"; my $username="all"; my $flagreserved="false"; my $COEERR=0; my @u; my @uid; while (@ARGV > 0 ){ $arg1=cleanString(shift,1); if ("$arg1" eq "-h") { useage; exit 0; } elsif ("$arg1" eq "-H") { coeMan("COE_COMP/UserMgmt/docs/man/$PRGM"); exit 0; } elsif ("$arg1" eq "-V") { print "VERSION: $VERSION\n"; exit 0; } elsif ("$arg1" eq "-f") { $flagreserved="true"; } elsif ("$arg1" eq "-s") { $scope=cleanString(shift,1); } elsif ("$arg1" eq "-n") { $username=cleanString(shift,1); } elsif ("$arg1" eq "-u") { $userid=cleanString(shift,1); } else { useage; exit 202; } } if ("$scope" eq "l" || "$scope" eq "local" ) { $scope="local"; $s="l"; } elsif ("$scope" eq "g" || "$scope" eq "global") { $scope="global"; $s="g"; } else { useage; exit 202; } if ("$username" ne "all") { $userid=coeExec("COE_HOME/bin/COE_get_user_id $username $scope"); $userid=cleanString($userid,0); } $coedat=coeFileConv "COE_USER/$scope/Profiles/.User.dat"; # User.dat format:: uid:username:fullname:::::: # get the UIDS $i=0; $COEDAT=readFile($coedat); if ("$userid" eq "all"){ while (<$COEDAT>) { $uid[$i++]=$_; } } else { while (<$COEDAT>){ if (/^$userid:/ || /:$username:/) { $uid[$i++]=$_; }} } close $COEDAT; foreach (@uid) { # $_=cleanString($_,3); chomp($_); @u=split(':'); if ("$flagreserved" eq "true") { print "$u[0]:$u[1]:$u[2]:$s:$u[3]:$u[4]:$u[5]:$u[6]:$u[7]:$u[8]\n"; } else { print "$u[0]:$u[1]:$u[2]:$s\n"; } } # if no such user is found, mark the exit as such if ($i == 0) { $COEERR=203; } exit $COEERR;