#!/usr/bin/perl -T -I/h/COE/lib -w use strict; use Coe; my $VERSION="1.1.4.1"; if (@ARGV == 0) { print "Usage: OS_get_user_data {-n username}|{-u uid}\n"; exit; } my $userid="dummy"; my $username="dummy"; my $uscope="local"; my $arg1; my $i; my $file; my $info; my @uid; my $OSFILE; while (@ARGV > 0 ){ $arg1=cleanString(shift,1); if ("$arg1" eq "-h") { print "HELP\n"; exit; } elsif ("$arg1" eq "-H") { print "HELP\n"; exit; } elsif ("$arg1" eq "-V") { print "VERSION: $VERSION\n"; exit; } elsif ("$arg1" eq "-n") { $username=cleanString(shift,1); } elsif ("$arg1" eq "-u") { $userid=cleanString(shift,1); } else { print "HELP\n"; exit; } } # get the User data $i=0; $OSFILE=openFile("/etc/passwd"); if ("$username" ne "dummy") { while (<$OSFILE>) { if (/^$username:/) { $uid[$i++]=$_; }} } else { while (<$OSFILE>) { if (/.*:.*:$userid:.*:.*:.*:/) { $uid[$i++]=$_; }} } close $OSFILE; #- print the User data foreach (@uid) { chomp(); $info=cleanString("$_", 3); print "$info\n"; } |