LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-26-2004, 08:56 PM   #1
eclapton1
LQ Newbie
 
Registered: Jun 2004
Posts: 7

Rep: Reputation: 0
Displaying fields in wtmp file?


Anyone have any idea on how to display the fields for each record stored in the wtmp file using C? Am I correct in thinking that the info stored in wtmp is in binary and that utmpx will be of some help? Being a beginner, I can come up with bits and pieces of what I might need in order to do the task, but have a harder time putting all the pieces together to form working code. I am assuming I need to include these bits of code:

#include <utmp.h>
#include <utmpx.h>

struct utmpx record;
fread(&record, sizeof(record), ???)

printf(??????)

Any assistance would be greatly appreciated. Thanks.
 
Old 06-26-2004, 09:51 PM   #2
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Rep: Reputation: 15
man getutent
man fread

You won't have to do the straight file operations then. If you want to do it manulally with fread:

struct utmpx record;
FILE fd = 0;

fd = fopen(name, 'r'); //Usally /var/run/utmp
fread(&record, sizeof(record), 1, fd);

printf("Whatever fields you want, check out the header\n");
 
  


Reply



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
Manipulating Fields Of Flat File Prasun1 General 10 09-29-2005 11:42 AM
Strange wtmp file ldp Linux - General 7 07-31-2005 04:24 PM
WTMP file pkrishna10 Linux - General 1 11-13-2004 07:47 AM
displaying file permissions Imyrryr Linux - Newbie 6 10-18-2003 10:06 PM
Displaying a certain line in a file. Mike_the_Man Linux - General 1 03-02-2001 10:12 PM

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

All times are GMT -5. The time now is 09:03 PM.

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