I've got a 'monitored' box that needs to send email alerts whenever a
login and logout occurs. All login accounts are heavily restricted and
use /bin/sh as their shell.
In /etc/profile I added:
who | mail -s "`hostname` LOGIN NOTICE (`whoami`)"
alerts@foo.com
which sends an email with the output of the `who` command, like this:
----------------
From:
narc@pooh.foo.com
To:
alerts@foo.com
Subject: pooh LOGIN NOTICE (kevin)
Date: 27 Feb 2004 10:44:41 -0701
kevin ttyp0 Feb 27 10:31 (10.10.10.1)
----------------
Customer wants the logout event to send the output of the `history`
command the same way. Since /bin/sh doesn't directly support logout
scripts the way /bin/csh does, I added the following to /etc/profile:
trap "~/.logout" 0
Then, I created a .logout file in my test user account (kevin) and did
`chmod +x ~/.logout`. In the .logout file I simply put:
history | mail -s "`hostname` LOGOUT NOTICE (`whoami`)"
alerts@foo.com
However, when the `history` command is executed from the .logout file,
it appears to run in a new session, because I get this in the email:
----------------
From:
narc@pooh.foo.com
To:
alerts@foo.com
Subject: pooh LOGOUT NOTICE (kevin)
Date: 27 Feb 2004 11:34:11 -0701
sh: fc: no history (yet)
----------------
Any ideas on this one?
...Kevin
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss