Python debug print the command
Question: Folks

I am not very up with Python but have inherited a load of Python scripts One
of which is given me a issue in that I am not 100% sure what one line is
running

What I need to do is print out the command line and its variables.

The line in question is

    
    
    ldapModify(userdn, mods, uri=uri)
    

What I am hoping to see is something like

    
    
    /usr/bin/ldapmodify xxxx cn=......
    

Can any kind soul help.


Answer: The Python ldap lib doesn't call on the ldap command line client, it binds
directly to the underlying system ldap lib.

If what you want is to know the values of the args passed to ldapModify, it's
quite simple: print them to sys.stderr :

    
    
    import sys
    try:
       ldapModify(userdn,mods,uri=uri)
    except Exception, e:
       print >> sys.stderr, "oops, ldapModify failed with '%s'" % e
       print >> sys.stderr, "userdns : '%s' - uri : '%s' - mods : '%s'" % (userdns, uri, mods)
       # and reraise the error so you get the whole traceback
       raise
    

