Run python script



I try to get python script working on nscp 0.4.4. So I did this in my nsclient.ini :


When I start nscp in test mode (nscp.exe test) I can see that the script is loaded

D     python Looking for: scripts\python\sample\
D     python Adding script: py_wmi_obj (scripts\python\sample\
D     python boot python
D     python Prepare python
D     python init python
D     python Loading python script: scripts\python\sample\
D     python Lib path: C:\Program Files\NSClient++\scripts\python\lib
E     python close failed in file object destructor:
IOError: [Errno 0] Error

(don’t know if the error is serious or not)

but when I type py_wmi_obj in prompt, it said that the command is unknown. I tried to put it in the external script like that

[/settings/external script/script]

but didn’t work, which look normal to me :-). What is the proper way to launch python script in nsclient++.


I have noticed this lately, not sure if it is related to something I have changed or not it usualy means you have some problem in the script… (Before you usually got a “on line 34 you have error x” but when I have seen that it has usually been calling

conf = Settings.get(plugin_id)
reg = Registry.get(plugin_id)

with out the plugin_id (as it was before)

I will try to improve this error message though…


Hum so you think it is a problem in the script ? I only tried with the sample script, no my own.


Ohh, had forgotten about that one…

A pretty (old) bad sample… a better sample plugin is scripts\python\

But yes it had exactly the problem i mentioned, pushed a new version but as I said the script has some issues so I would look in the other sample script…


In 0.4.4 on win8 x64 doesn’t work (launching via nscp py --script=<thescript>):

  • (IOError [Errno 0] etc…)

The output is always the same :

IOError: [Errno 0] Error


And by the way, how can I launch a python script from the api or via the scheduler ?




In 0.5.0 I gixed this:

$ nscp py
Command not found:
Usage: nscp py [execute|list|install] --help

Adding in execute:

$ nscp py execute
L     python My god: its full of stars: true
L     python Adding a simple function/cmd line
L     python Unloading script...


I am trying to run python scripts by using the “nscp py execute --script=” method. So far I can get the provided to work but if I run most of the other scripts I get a error similair to: nscp python execute E python Failed to load script: C:\Program Files\NSClient++\scripts\python\ c:\source\master\modules\PythonScript\PythonScript.cpp:220 E python close failed in file object destructor: IOError: [Errno 0] Error c:\source\master\modules\PythonScript\script_wrapper.cpp:173

Are there any specifics needed in order to get the other python scripts running or what makes the special? Are there any users of NSClient++ who has managed to get custom Python scripts running or are most defaulting to external Python.exe?

I am using NSCP- on Windows by the way.


I do confirm that the sample python script raises an error and I logged an issue with a workaround here:


Running the script seems to work for me:

[email protected] c:\source\build\x64\dev
$ nscp python execute
L     python -+---==(TEST INSTALLER)==---------------------------------------------------+-
L     python  | Setup nessecary configuration for running test                           |
L     python  | This includes: Loading the PythonScript module at startup                |
L     python  | To use this please run nsclient++ in "test mode" like so:                |
L     python  | nscp client --boot --query py_unittest                                   |
L     python -+--------------------------------------------------------==(DAS ENDE!)==---+-


Nope- It doesn’t. There is problem with line in


If you comment it, script works. If not- there is I/O error. Tested with current version on Windows.

It looks like problem with python wrapper.