Check User Script

I have created check user script to list the username, email alias, and the disk usage of the user. I hope this will give you some ideas preparing your own check user script.

#***********************************************************************
#!/bin/bash
#Script by Jeffrey Dante
#Check User if available
#List the email alias
#Show the directory usage

if [ $(id -u) -eq 0 ]; then
cat /etc/passwd | awk -F: ‘{print $1}’ | grep -w $1
if [ $? -eq 0 ]; then

# email: username
cat /etc/aliases | grep -w $1 | awk -F: ‘{print $1}’

# Check User Disk Usage

LETTER=`/bin/echo $1 | /bin/awk ‘BEGIN{FS=””}{print $1}’`
DU=/usr/bin/du
echo “Disk Usage:”
$DU -msh /mnt/emaildata/$LETTER/$1/Maildir | awk ‘{print $1}’

exit 1

else
echo “$1 does not exists!”
fi

else
echo “User verification Done!”
exit 2
fi

#***********************************************************************

Output should look like this
user
email/s
usage

[root@test.com jedscripts]# ./usercheck.sh jepdante
jepdante
jeffrey.dante@test.com
jeffrey_dante@test.com
Disk Usage:
55M

Advertisements

Mag-iwan ng Tugon

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Baguhin )

Twitter picture

You are commenting using your Twitter account. Log Out / Baguhin )

Facebook photo

You are commenting using your Facebook account. Log Out / Baguhin )

Google+ photo

You are commenting using your Google+ account. Log Out / Baguhin )

Connecting to %s