hi, i'm trying to write a script to check if the home directories of users are set correctly. below is an extract of the script
Quote:
dirperm=$(ls -ld $(echo $user | awk -F: '{ print $6 }') | awk -F ' ' '{print $3}')
#echo $username
if [ "$username" == "$dirperm" ]
then
echo $username [PASS]
else
if [ -z "$dirperm" ]
then
echo $username [FAIL - Directory Does not Exists!]
else
echo $username [FAIL]
|
here, i am trying to put the name of the owner of the home directory into the variable
dirperm (by reading lines in /etc/passwd). however, it seems that when the directory is invalid, the "does not exist" error message pops out and messes up the script output. how can i do a check to see if the output of
ls -ld in the script is valid?