
01-04-2009
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by roddo90
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
|
Please put code between [code] tags.
Quote:
Code:
dirperm=$(ls -ld $(echo $user | awk -F: '{ print $6 }') | awk -F ' ' '{print $3}')
|
I don't understand exactly what you are trying to do, but that looks far more complicated than it need be. For example, couldn't part of that be done more easily with:
Quote:
Code:
#echo $username
if [ "$username" == "$dirperm" ]
|
The == operator is not standard.
Quote:
Code:
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,
|
What do you mean by "invalid" and where do you test for that?
Quote:
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?
|
What do you mean by "invalid"? If you want to check whether it exists, use test -d.
|