DXCMD with the -getstate option via a batch does not return any information

  • 7006835
  • 13-Sep-2010
  • 26-Apr-2012


Novell Identity Manager 3.5.1
Novell Identity Manager 3.6
Novell Identity Manager 3.6.1


When accessing dxcmd via interactive prompts the getstate option for a driver returns the state correctly. However, when accessing dxcmd and passing the parameters via a batch, shell script, etc.. it does not return anything when using the -getstate option.


It isn't designed to show the state, it is designed to return the state. When scripting, particularly on Unix, you often don't care about actually seeing the result. Rather, you want the result in a form that you can do something with it programmatically. The non-interactive dxcmd options (like -getstate) are designed to be used with scripting. So the dxcmd program returns the result as the (numeric) result of running the program. This means you can test the result and do something useful (such as translating the numeric value into a string and displaying it, if you were so inclined). In UNIX (most shells, anyway) you use $? in a shell script or on the command line to get the return value of the last program run. On Windows the syntax is %errorlevel%. For example. If you want to print out the state on Windows. Add the following as the last line in the dxcmd.bat file. "echo program return == %errorlevel%"
For IDM 3.5 an option (-s) has been added to dxcmd that causes the result to be written to stdout. This might be more straightforward to understand, but it is somewhat harder to use in scripting. In any event, the primary reason it was added was because of a limitation on the return value on many UNIX versions (including Linux). Basically, the program return value is limited to an unsigned 8-bit value. What this means practically is that error codes from edirectory requests aren't intelligible when returned that way. To get around this limitation the -s option was added so that you can use the "backquote" shell method to put the dxcmd result into a form useful for scripting.