bash - How to get the exit status of htpasswd? -


i working on shell script ease htpasswd management accounts.

i trying check if htpasswd created using expected exit status docs

this have far:

existing htpasswd:

local _result=$(htpasswd "${htpasswd_location}" "${_htpasswdlogin}") 

new htpasswd:

local _result=$(htpasswd -c "${htpasswd_location}" "${_htpasswdlogin}") 

for reason, being successful not able capture exit status.

this check:

if [ "${_result}" = "0" ];     echo "user added .htpasswd file" else     echo "failed add user .htpasswd file" fi 

is there better method exit status?

you can do:

if htpasswd -c "${htpasswd_location}" "${_htpasswdlogin}";     echo "user added .htpasswd file" else     echo "failed add user .htpasswd file" fi 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -