home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13435 < prev    next >
Encoding:
Text File  |  1992-11-15  |  1.6 KB  |  45 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!ukma!wupost!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!osiris.cso.uiuc.edu!gordon
  3. From: gordon@osiris.cso.uiuc.edu (John Gordon)
  4. Subject: Re: A few more quick C questions...
  5. References: <c-r1bx#@rpi.edu>
  6. Message-ID: <BxrqsK.Kr4@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois at Urbana
  9. Date: Sun, 15 Nov 1992 17:48:18 GMT
  10. Lines: 33
  11.  
  12. cecchinr@hornsby.cs.rpi.edu (Ron Cecchini) writes:
  13.  
  14. >Hi again -
  15.  
  16. > Thanx to everyone who responded to my read/write question of a few days ago.
  17.  
  18. > I just have a couple of *quick* C questions:
  19.  
  20. >1) Is there a command to see if a file exists?
  21. >   [Can't just use fopen() - it returns NULL for more than one reason...]
  22.  
  23.     Try access().
  24.  
  25. >2) Is there a command to determine a file's size?
  26. >   [I think the data structure pointed to by a FILE contains a ->_cnt feild
  27. >    that can be used - I'll try it in a minute...]
  28.  
  29.     Try fstat(), in particular the st_size element.
  30.  
  31. >3) Is there a command to determine if a user is logged in?
  32. >   [I don't want to bother with a system("who | grep user > temp"), etc.]
  33.  
  34.     Well, if you REALLY wanted to avoid the "who" route, you could
  35. write a program that reads the /etc/utmp file, which is supposed to
  36. contain a list of current users.  The format is pretty weird, though.
  37.  
  38. >4) Is there a command to determine if a user is running a certain process?
  39.  
  40.     Err....how about "ps" ?
  41.  
  42. ---
  43. John Gordon                        My incredibly witty saying has been 
  44. gordon@osiris.cso.uiuc.edu         Politically Corrected into oblivion.
  45.