#!/bin/bash
#####################################################################
# file name: sy_4
# Author : Suresh Yadagiri
# date : August 10 2010
# Description:
# This script prompts user id and
# displays user login name, user name and home
# directory of the user. if user id is not
# found in /etc/passwd file then it displays
# appropriate error message
#######################################################################
if [ $# -gt 0 ]
then
echo "No arguments expected"
echo "Usage: $0"
exit 1
fi
echo -e "Enter user id :\c"
read userid
userloginname=`grep ":$userid:" /etc/passwd | cut -f1 -d :`
#Display error message is userid is not found
if [ "$userloginname" == "" ]
then
echo "user id is not found. Account may be not local account"
exit 1
fi
#display user information
#userloginname=`grep ":$userid:" /etc/passwd | cut -f1 -d :`
username=`grep ":$userid:" /etc/passwd | cut -f5 -d :`
homedirectory=`grep ":$userid:" /etc/passwd | cut -f6 -d :`
echo "user login name : $userloginname"
echo "user name : $username"
echo "user Home directory : $homedirectory"
No comments:
Post a Comment