ActiveState Powered by ActiveState

ActiveState Community


How to capture error messages...

Posted by fabster01 on 2008-01-15 04:11

Hi I am a new bie and have been coding a relatively easy structured programming method.

I have a snippet of my program which will:

#-----Running LDAPMODIFY Against The Ldif File Created-----#
sub RunUpdate
{
	print "--Updating Directory server. Please wait for a moment....\n\n";	
	my $resultLdapSearch = `ldapmodify -h $ldap_server -D "cn=Directory Manager" -w $dir_mgr_pwd -f $ldap_modify_file`;
	#print "resultLdapSearch: $resultLdapSearch\n";
}

When running the program I get a output error due to the ldapmodify command is trying to update and existing field, as shown below:

bash-2.05# perl 4-run_update_attributes.pl

*****************************************************************************
Step #4 - The Script WILL NOW Update The Users "Company" and "Co" Attributes
*****************************************************************************

Do you want to continue [y]:
--Updating Directory server. Please wait for a moment....

ldap_modify_s: Type or value exists

***********************************************************************
See Result:
-----------
Log Output file (verified): 01152008.log
***********************************************************************

As you notice, the error "ldap_modify_s: Type or value exists" appears from the "ldapmodify" that I executed. I need to know how do I capture this value and will write some codes to handle this error.

Please advice.

-->