![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jul 2005
Posts: 10
Rep Power: 0
![]() |
I am writting a daemon in python which should start at system start up with all inet.d services
on an NIS server. Then it should listen to any user login and then start a new process for that user on his login which will continue throughout his entire session. Can anyone give any help or any suggestion or any useful links. thinkgeek |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Well which part do you need help with? Just doing so in general? If so, that's quite a specialized thing you're trying to do... you're probably better off asking someone with a more extensive collection of information on these kind of things.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jul 2005
Posts: 10
Rep Power: 0
![]() |
I want my daemon to start at system start up as other (start|stop|restart) services/daemons. It work is to listen to user logins. Whenever a user logins at the terminal(local or NIS client) it should get the username. It will start a new thread which will run throughout the session of that user. This should be done for any user who logs in. But I want my daemon to be smart enough to know immediately who is login into the system, so that it can respond accordingly.
|
|
|
|
|
|
#4 | ||
|
Programmer
Join Date: Feb 2005
Posts: 54
Rep Power: 4
![]() |
Quote:
Quote:
|
||
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jul 2005
Posts: 10
Rep Power: 0
![]() |
More details...
1. I am using Redhat Enterprise Linux
2. Could you explain how to get username from /var/run/utmp. It is in some different format which can't be understood. |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Feb 2005
Posts: 54
Rep Power: 4
![]() |
Ok then, check out /etc/init.d, it is full of scripts that start programs on boot. They are somewhat simple bash scripts, I would make a copy of one of them and change what you need. Then use the program /sbin/chkconfig to setup the script to run on boot
The utmp file is in a binary format. You can find out the exact structure by checking out the man page, "man utmp". |
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Alternatively you can spawn a new who process every few seconds and read its output. That would be easier than parsing /var/run/utmp, but you'd get a performance hit for spawning a new process so often - i'd go with the file parsing option myself.
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Jul 2005
Posts: 10
Rep Power: 0
![]() |
File parsing the /var/run/utmp
Quote:
|
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: Jun 2005
Location: |\|[][]B |_4|\|D
Posts: 41
Rep Power: 0
![]() |
couldn't you just have a program that when someone logs in autoruns telling this program that they have logged in? wouldn't that be much simpler....
|
|
|
|
|
|
#10 | ||
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
Quote:
|
||
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|