To display all the /etc/passwd fields for users passed on the command line : getpwnam « System Functions « Perl






To display all the /etc/passwd fields for users passed on the command line

      


#!/usr/bin/perl -w 
  
foreach $username (@ARGV) {
    ($name, $passwd, $uid,$gid, $quota, $comment,$gcos, $dir, $shell) = getpwnam($username);
  
    print "name    = $name\n";  
    print "passwd  = $passwd\n";  
    print "uid     = $uid\n";  
    print "gid     = $gid\n";  
    print "quota   = $quota\n";  
    print "comment = $comment\n";  
    print "gcos    = $gcos\n";  
    print "dir     = $dir\n";  
    print "shell   = $shell\n\n";  
} 

   
    
    
    
    
    
  








Related examples in the same category

1.Test a UNIX password
2.Values Returned by getpwnam
3.The getgrnam function retrieves the group file entry corresponding to a particular group name.