-3

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.

JPvdMerwe
  • 3,328
  • 3
  • 27
  • 32

2 Answers2

0

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
bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
0

Before the line in question, you could place a call to python's interactive debugger. Then you can print out the variables in question:

import pdb
pdb.set_trace()
ldapModify(userdn, mods, uri=uri)

At the (pdb) prompt you can print out the value of any or all of the variables.

Here's a link about the debugger.

trusko
  • 5
  • 1