[NTLUG:Discuss] Login processing for RH 8.0

Darin W. Smith darin_ext at darinsmith.net
Mon May 12 16:23:48 CDT 2003


On Mon, 12 May 2003 20:57:01 +0000, jay linux <jaylinux at hotmail.com> wrote:

> Hello,
>
> I'm fairly new to Linux. I'm trying to creat a bash (or whatever) script 
> that runs every time I *login*. I want it to tell me when I last logged 
> in and the number of times I have logged in before.
>
> I was going to execute 'last' and then get the info I want from it. Is 
> that how it's normally done?
>

Yes, that is probably the easiest way.  If you do 'last | grep myuser | wc - 
l' it will tell you how many times you've logged in (since the 
/var/log/wtmp file was created...probably wiped whenever you reboot, so you 
may have more work to do if you want to preserve across reboots).  Also, 
this number will include your current login.

You could create a shell script to do everything you want and exec it from 
.profile or (better, IMO) .bashrc.

> Which file do I hook this into? The .profile? When I login using the RH 
> login interface I'm not even sure where messages would come out since I'm 
> not automatically put into a tty or shell or anything....
>

The problem is that it will be logged to the console, so unless you have 
one up, you won't see it.  It is possible to keep a console open on the 
XDM/KDM/GDM login desktop, as well as your own, but I don't know if you 
want to do that.

Now, if you put it in one of the files (like .bashrc) that gets executed 
whenever you start an interactive shell session, then anytime you open a 
terminal, you should get it, echoed to that pty.

-- 
D!
Darin W. Smith
AIM: JediGrover



More information about the Discuss mailing list