The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
su ?? Who logged in First ?? varungupta UNIX for Advanced & Expert Users 2 01-24-2008 04:10 PM
last logged on info nokia1100 Shell Programming and Scripting 1 04-07-2007 12:32 PM
Need help getting logged in to server mayewil SUN Solaris 1 10-26-2006 04:06 PM
know who logged and logged out with their timings vkandati UNIX for Dummies Questions & Answers 3 03-09-2005 10:04 AM
Is user logged on?? provo UNIX for Dummies Questions & Answers 1 12-07-2001 05:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-22-2008
mrhosseini mrhosseini is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 8
logged in or logged out?

I have wrote a service with c++ which is always run and now I want to get with it the exact time in that the user log in or log out and then run a script. but the problem is that how could i find that the user logged in or logged out with out checking something frequently?
thanks
  #2 (permalink)  
Old 07-22-2008
Sivaswami's Avatar
Sivaswami Sivaswami is offline
Registered User
  
 

Join Date: Mar 2007
Location: India
Posts: 62
you can use wtmp & utmp / implementation of who.
  #3 (permalink)  
Old 07-22-2008
mrhosseini mrhosseini is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 8
thanks, but i think this can't be useful.i think i did not describe the problem correctly. the service should do an action when user logged in and another when user logged out.
  #4 (permalink)  
Old 07-22-2008
mrhosseini mrhosseini is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 8
the service has to send a message to a server and one part of the message is that if any body logged in or out.
  #5 (permalink)  
Old 07-22-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Running the moral equivalent of tail -f on wtmp will block until the file is written to with a new record, so it might fit your needs after all.

See also http://groups.google.com/group/comp....3d5311b1fec584
  #6 (permalink)  
Old 07-22-2008
mrhosseini mrhosseini is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 8
sorry! but I think the program again has to always wait for a change
  #7 (permalink)  
Old 07-22-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The read() blocks when no data is available. The sleep(1) happens when no data is available; you can adjust for how long it sleeps before it tries again, obviously. But this is admittedly a workaround. I don't think there is a platform-independent way to trigger on log-in or log-out events. If you have dbus or similar, maybe that has the facility you are looking for.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0