bash - Not able to suppress the output in shell script -
i using following code perform operation. everytime "ldap_bind: invalid credentials (49)" getting printed on console. dont want printed on console , rather should suppressed. how achieve it? code:
ldap_conf="/etc/opt/nokia/ldapserver.conf" binderror="ldap_bind: invalid credentials (49)" basedn=`cat $ldap_conf | grep basedn | cut -d " " -f2` verify=`su - omc -c "ldapsearch -x -n -d "uid=$username,ou=people,ou=accounts,$basedn" -w $newpswd"` if echo "$verify" | grep -q "$binderror"; printpasswdlog "${err}" "bind ldap server failed" else printpasswdlog "${inf}" "bind ldap server successful $username " fi i getting below output:
ldap_bind: invalid credentials (49) wed jun 3 12:45:56 eest 2015| info | bind ldap server successful nwi3system
if want suppress error messages, put @ start of script:
exec 2> /dev/null but don't want that. it's sufficient do:
verify=$(su - omc -c "ldapsearch -x -n -d uid=$username,ou=people,ou=accounts,$basedn -w $newpswd" 2> /dev/null) but don't want either. why want throw away error message replace 1 contains less information?
Comments
Post a Comment