On Jan 22, 2008 11:15 PM, Tom Phoenix <[EMAIL PROTECTED]> wrote: > What about this data? > > fred:x:42:42:Fred Flintstone:/home/fred:/bin/bash > barney:x:99:99:Barney Rubble:/home/barney:/bin/bash > fred:x:69:69:Fred Astaire:/home/fred:/bin/bash > dino:x:69:69:Dino:/home/dino:/bin/bash >
I see. > As I understand your code, it will drop Fred Astaire for having a > username that had been seen before. Then, it will drop Dino, for > having a UID that had been seen before, even though the line with that > UID was itself dropped. Is that what you want it to do? No really. But I guess this situation can not be avoided with my code. > > Maybe you can invent a better solution. For example, instead of > dropping users whose UID has been used elsewhere, perhaps they could > be assigned new UIDs; I imagine that would make the users happier. > Duplicate usernames aren't so simple as that, but aren't generally too > difficult to handle programmatically. > Assigning different UID is my long term goal but in short term, I can not change anything. These users are system users not just ordinary users, changing their UID will create problems. I merge two different /etc/passwd file from two different UNIX platforms (Solaris and Linux), then I will keep only one of the users (the first seen) and discard the second one. That will build a unique list as far as username, then I look for UID conflict, this is the time that start losing users that I need to operate the system. I "invented" another algorithm but my limited perl knowledge is holding me back. If I could look for `uname -s` in geco field (5th) in the password file, then I did not have to sort by username and would keep any user that has the word `uname -s` in its geco. Is this a right approach to look for `uname -s` in the 5th field? my $system = `uname -s` while (my $line = <PASSWDfh>) { my ($user,$pass,$uid,$gid,$geco) = split /:/, $line .... # here is where I get stuck my $result = grep( /$system/, $geco); print $_ if $result; } > Cheers! > > --Tom Phoenix > Stonehenge Perl Training > -- This e-mail address is not monitored so please do not send me anything important here. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/