On Mon, Feb 21, 2005 at 12:41:11PM +1100, Caveman wrote:
> Hi,
>
> Looking for a way to get a notification when a user logs in via email?
> The only why I have been able to think of was to move /bin/sh and
> /bin/bash and create bash files to load these along with sending a
> email. But I was wondering if there is a easier way ? Or a program
> designed for this ?
>
> Thanks.
>
> Caveman
Hi,
I'm posting a half-finished answer here, but it's lunch-time...
Here goes:
last | grep $USER | grep "still logged in" &> /dev/null
if [ "$?" -eq 1 ]; then
echo "$USER logged in" | mail -s "$USER logged in" root@localhost
fi
First line checks if $USER is already logged in (btw, doesn't work for
su $USER, only for real logins...) and depending on the exit status of
that line, we send an e-mail. I am not happy with the first line, so you
should try to find another way of determining if $USER is logged in...
The whole goes into /etc/profile
Hungry,
--
Andreas Rippl -- GPG messages preferred
Key-ID: 0x81073379
Attachment:
signature.asc
Description: Digital signature