LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2007, 01:49 AM   #1
narainhere
LQ Newbie
 
Registered: Jul 2007
Posts: 12

Rep: Reputation: 0
Post Finger command to list all the user names


Hi all,
I am having a perl script which should mail a report.I need to figure out the Real names for the user-id's .The problem is I need to retrieve the real-names for all the user-id's on the server.Is there a way to do this?
 
Old 09-03-2007, 02:38 AM   #2
adam_blackice
Member
 
Registered: Apr 2006
Location: /*Egypt */ //cairo
Distribution: Ubuntu 7.04 , SLED 10 , Fedora , RHEL 5
Posts: 312

Rep: Reputation: 32
hello

i think the proper way is to go to the /etc/passwd file and then extract the fields you want and then pass that to variable and use it to get the list if the real name

here is the code that u will use

Code:
#Author: Black-Ice
#Date: 20/6/2007
#!/usr/bin/perl -w
use strict;

my $file = "/etc/passwd";

open (han1, "$file") || die  "error opening file: $!";


my @newrecords = ;

foreach (@newrecords) {

my @columns = split /:/;

my $username = $columns[0];
my $x = $columns[1];
my $userid = $columns[2];
my $groupid = $columns[3];
my $realname = $columns[4];
my $homedir = $columns[5];
my $shellpath = $columns[6];

#then u can echo the field that you want to disply
either u can do it throw a shell script and that will be good too


Code:
cat /etc/passwd | cut -d : -f "the field of the real name in the /etc/passwd file "
 
1 members found this post helpful.
Old 09-03-2007, 04:05 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by adam_blackice View Post
Code:
cat /etc/passwd | cut -d : -f "the field of the real name in the /etc/passwd file "
no need for cat
Code:
cut -d":" -f5 /etc/passwd
 
Old 09-03-2007, 04:56 AM   #4
adam_blackice
Member
 
Registered: Apr 2006
Location: /*Egypt */ //cairo
Distribution: Ubuntu 7.04 , SLED 10 , Fedora , RHEL 5
Posts: 312

Rep: Reputation: 32
you are right but i used to do it like that
 
  


Reply

Tags
users


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
List of All user accounts from command line sniff Linux - General 4 07-09-2006 12:02 PM
finger and cut command Craig Bowes Linux - Newbie 3 10-09-2004 01:49 PM
PHP List /home/'user' then finger 'user' Caboose Programming 1 09-22-2004 05:12 AM
What command can list the userids in various user groups? davidas Linux - Newbie 1 04-16-2004 10:01 PM
finger - command rob99 Linux - Networking 2 02-02-2003 12:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration