how to write a C program which has the function of "Who"?


 
Thread Tools Search this Thread
Top Forums Programming how to write a C program which has the function of "Who"?
# 1  
Old 10-09-2003
how to write a C program which has the function of "Who"?

how to write a C program which has the function of "Who"?
how to read the user informations---the data structures stored in /var/adm/utmpx and display them?

somebody plz help!!!
# 2  
Old 10-10-2003
this seems like homework, is it? see rule six please:

(6) Do not post classroom or homework problems.

you can name functions in C whatever you want. if you want a function called 'Who' then name it 'Who'. C programs will generally have more than one function, and always have at least one function, always called 'main()'.


see the man pages for 'utmp', take a look at the 'see also: ...' at the bottom.
# 3  
Old 10-10-2003
You're taking him too literally, norsk. He doesn't literally mean a function named who. He want to duplicate the who program.

Also, this would not a very poor choice for a homework assignment. That would be especially true at this point in time. The format of the utmp file is evolving right now. A portable answer to this question really is not possible. A portable who program would need a ton of ifdefs.

Your file may be named utmp or utmpx or both. You will want the x version if you have it.

Five years ago I could have told you to just call getutmp() in a loop, select the interesting records, and print them out. Now you may have getutmpx(), if so, use that. Both will be mentioned in "man getutmp" if that exists. Or you may just have a "man getutmpx".

But in any event, just call whichever in a loop, select the interesting records, and display them.
# 4  
Old 10-10-2003
ohhhh i get it... 'function' as in works like...my fault. Smilie
# 5  
Old 10-10-2003
I see that I fumbled too. I shouldn't post until I wakeup. I meant to say this "would be a poor choice for a homework assignment".
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Problems with "write" and "wall"

Hello, I am using VirtualBox to simulate a small network with two Linux computers, the host is Mac OS X. My problem is that I can't send "write" and "wall" messages from the host to one of those Linux computers. Here is what works: - The virtual Linux computer answers "ping" messages that have... (5 Replies)
Discussion started by: 123_abc
5 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. HP-UX

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people! I've got this own library: -------------------------------------------- Personal.h -------------------------------------------- #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdarg.h> #include <string.h> ... (0 Replies)
Discussion started by: donatoll
0 Replies

6. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

7. Shell Programming and Scripting

communicating wth another user aside from "wall" and "write"

Hi, Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I... (6 Replies)
Discussion started by: Deanne
6 Replies

8. Programming

how could i make a program mixed with many "|", "<" and ">"

I have written following code to do: ls -l | wc -w, it works: but when there are not only a single "|", if there are more such as: ls -l | sort -r | sort | sort -r, This program does not work, i want to know how could i deal with it when there are more "|", another situation is that, if it mixes... (2 Replies)
Discussion started by: strugglingman
2 Replies

9. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies
Login or Register to Ask a Question