Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Dorman accounts
Results 1 to 6 of 6

Thread: Dorman accounts

  1. #1
    Associate
    Join Date
    Mar 2006
    Posts
    21

    Dorman accounts

    What is a good way to identify "dormant" accounts? I.E., this account was last logged in 2 months ago?

    Also, what would be the easiest way to identify locked accounts?

    Thanks, John.

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    What is a good way to identify "dormant" accounts?
    Something like this small scripting
    Code:
    #!/bin/sh
    
    #
    # A small script to list a users last login
    # it will list every user in the /home directory with
    # last login exceeding one month
    #
    
    for d in `ls /home/` ; do
      LOGIN=`last $d | head -n 1 | grep -v "still logged in" \
                     | awk '{print $3 " " $ 4 " " $5}'`
      if [ "$LOGIN"x != x ]; then
        case $LOGIN in
           "  ")
             ;;
           *)
             # we're dealing with a valid user who isnt online at the moment
             # calculate how many month it's been since last login
             OLD_DATE=`date -d "$LOGIN" +%Y%m%d`
             NEW_DATE=`date +%Y%m%d`
             DIFF=`echo "$NEW_DATE-$OLD_DATE"| bc`
             if [ $DIFF -ge 100 ]; then
               # display users with more than 1 month stale login
               MONTH=`echo "$DIFF/100" | bc`
               DAYS=`echo "$DIFF%100" | bc`
               echo -n "User $d was last logged in $MONTH month"
               if [ $DAYS -ge 1 ]; then
                 echo -n " and $DAYS day"
                 if [ $DAYS -ge 2 ]; then
                   echo -n "s"
                 fi
               fi
               echo " ago"
             fi
             ;;
        esac
      fi
    done
    Last edited by redhead; 09-27-2006 at 04:08 PM.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3
    Associate
    Join Date
    Mar 2006
    Posts
    21
    Thanks Redhead. I'm a linux newbie. When I run the script, I get:

    [c108596@McPbsAM c108596]$ ./dormant
    : bad interpreter: No such file or directory

    And as you can see, I do know how to spell dormant - couldn't tell it from the thread title though :-)

    John.

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    You need to make the file you saved the script as executable ie:
    > chmod +x dormant
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  5. #5
    Associate
    Join Date
    Mar 2006
    Posts
    21
    I called myself already doing it:

    [c108596@McPbsAM c108596]$ ls -lah dormant
    -rwxrwxrwx 1 c108596 c108596 1.1K Sep 27 13:33 dormant
    [c108596@McPbsAM c108596]$

    Still the same symptoms.

  6. #6
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    Thats odd... On my system it seems to work fine:
    redhead@fenris{57} ~/Programming/Scripts> ./dormant.sh
    User redhead was last logged in 1 month and 2 days ago
    redhead@fenris{58} ~/Programming/Scripts> last redhead | head -n 1
    redhead :0 Sun Sep 1 00:56:36 2006
    redhead@fenris{58} ~/Programming/Scripts>
    Afer a bit of searching on google... Actualy the first (or second) hit, it is discussed as a possible problem with the <cr> vs. <cr/lf>
    It is suggested, that you see if the first line of the script is truely ending with a <cr>, to quote the post:
    Depending on the vi clone you are using, the carriage return may or may not be displayed. To be sure, run:
    Code:
    head -1 scriptFile.sh | od -c | head -1
    and check if the output looks like
    Code:
    0000000 # ! / b i n / s h \n
    Last edited by redhead; 10-03-2006 at 07:48 PM.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

Similar Threads

  1. user accounts
    By trace in forum Windows - General Topics
    Replies: 2
    Last Post: 07-06-2005, 08:47 PM
  2. outlook accounts troubleshoot help please
    By kaotik_good in forum Windows - General Topics
    Replies: 1
    Last Post: 02-15-2005, 09:46 PM
  3. Webserver Accounts
    By xin in forum Linux - Hardware, Networking & Security
    Replies: 13
    Last Post: 06-28-2002, 09:46 AM
  4. multiple accounts in kmail
    By chadm1967 in forum Linux - General Topics
    Replies: 7
    Last Post: 12-27-2001, 12:06 PM
  5. Backing up user accounts
    By tolstoy in forum Linux - General Topics
    Replies: 7
    Last Post: 11-28-2001, 08:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •