【发布时间】:2014-07-22 22:14:49
【问题描述】:
我正在编写一个 shell 脚本来简化帐户的 htpasswd 管理。
我正在尝试检查是否使用来自docs 的预期退出状态正确创建了 htpasswd
这是我目前所拥有的:
现有的 htpasswd:
local _result=$(htpasswd "${HTPASSWD_LOCATION}" "${_htpasswdLogin}")
新的 htpasswd:
local _result=$(htpasswd -c "${HTPASSWD_LOCATION}" "${_htpasswdLogin}")
由于某种原因,这是成功的,但我无法捕获退出状态。
这是我的支票:
if [ "${_result}" = "0" ]; then
echo "User successfully added to the .htpasswd file"
else
echo "Failed to add the user to .htpasswd file"
fi
有没有更好的方法来获取退出状态?
【问题讨论】:
标签: bash shell centos .htpasswd