how can i creat a program so that it can notifiy me everytimez someone logz in to there shell account (my comp)... please tell me itz simple...
how can i creat a program so that it can notifiy me everytimez someone logz in to there shell account (my comp)... please tell me itz simple...
You could set something up in their .bashrc file to send you a quick email.
echo "USERNAME logged in at `date`" | mail root
But then you have to make their .bashrc file read only to them (owned by root, perm = 700), and if they want some lines added, that could get annoying. Plus if they're connecting to an X serverm it will send you an email every time they open up a term emulator.
In any case, that's the simplest way I can think of.
starX
www.axisoftime.com
do you have a sample script on how to do thiz..?
that line I gave you IS basically the script, but I thought of a way to make it better. put this line into /etc/bashrc
echo "$USER logged in at `date`" | mail root
If you put it into /etc/bashrc, then it will affect everyone's log in across the system, so you don't have to worry about their individual .bashrc files, and they never have to know you're doing it.
It'll work, I promise.
starX
www.axisoftime.com
how can i make that show me the ip add to...?
now you're making this more complicated...
if you really want the whole kitten kaboodle of information on who just logged in on what from where and when, try this on for size:
who | grep $USER | mail root
This runs the who command, and greps the output for a line containing the username of the person who just logged in. It will give you their user name, the pts they're logged in on, the date/time they logged in, and the ip name of where they've logged in from.
starX
www.axisoftime.com
i did what you told me and i got an error
here is the error that i got...
bash: $: command not found
/usr/sbin/sendmail: No such file or directory
how can i fix this..?
you can get the ip i dunno the exact name but if you will scroll through "set" you will see a environment varialble . i think it's HOSTIP or something starting with HOST.i am on windows so cannot check right now ;(
my guess is that you use the dollar sign independent of the USER string.
$USER is an environment variable, if you put the two together, you'll get the username you're looking for. You didn't by any chance forget the grep, did you??? And perhaps mail is actually a symlink on your system. Check that out and see. mail is installed in /usr/bin on my system. What I gave you does work, but you might have some thingsconfigured differently than I do. And like I said, that $ has to go with USER, or else it won't work.
starX
www.axisoftime.com
---------------
starX
www.axisoftime.com
the best way to access each and damn thing is not through the environment variables as they can be changed but it could be by peeping in the /proc folder .
you can even determine the kind of hardware or every imaginative thing you can think of... but do remember few files are locked and moreover they keep on changing .changing them might kill the penguin ..
for example you will have a directory in the proc folder with your bash userID nos and in that all that is related to your environment will be put .