I am working on a shell script to easily manage accounts. I want to have an option to enable and disable shell access (which is easy) but the tricky part is finding if an account already has shell access so my script can show the proper options.
This is what I currently have:
Note: $account
is the given account
function checkIfShellAccess
{
ret=false
getent passwd $account >'/bin/bash' 2>&1 && ret=true
if $ret; then
HAS_SHELL=1
else
HAS_SHELL=0
fi
}
My issue is: When I run my script and check if the user has shell access I get the following notice:
line 241: /bin/bash: Text file busy
line 241 is:
getent passwd $account >'/bin/bash' 2>&1 && ret=true
I am using: CentOS release 6.5 (Final)
Thanks for any help on this.