문제

나는 쉘 스크립트를 사용하여 HTPASSWD 관리를 쉽게 할 수 있습니다.

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
.

출구 상태를 얻는 것이 더 나은 방법이 있습니까?

도움이 되었습니까?

해결책

할 수 있습니다 :

if htpasswd -c "${HTPASSWD_LOCATION}" "${_htpasswdLogin}"; then
    echo "User successfully added to the .htpasswd file"
else
    echo "Failed to add the user to .htpasswd file"
fi
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top