Thread: login

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    login

    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...

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    do you have a sample script on how to do thiz..?

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    how can i make that show me the ip add to...?

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    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..?

  8. #8
    Registered User rohit's Avatar
    Join Date
    Feb 2002
    Posts
    69
    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 ;(

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  10. #10
    Registered User rohit's Avatar
    Join Date
    Feb 2002
    Posts
    69
    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 .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unable to login to facebook
    By zykostar in forum C# Programming
    Replies: 4
    Last Post: 03-30-2010, 02:04 PM
  2. Login
    By brietje698 in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2007, 09:51 AM
  3. Having problems with a login script...
    By Junior89 in forum C++ Programming
    Replies: 6
    Last Post: 01-06-2006, 12:05 PM
  4. login script - URGENT!!!
    By linzeeuk in forum C Programming
    Replies: 5
    Last Post: 05-05-2003, 02:26 PM
  5. Replies: 7
    Last Post: 07-19-2002, 11:49 AM