Question
How do I configure a Python Agent Plug-in?
Environment
Local Data Processing
Answer
First make sure python is in your user & system path.
We also introduced a requirement that scripts on Windows now need a Unix-style shebang line at the very top, which Local Data Processing then interprets ie..
At the start of your python script it is recommended you set he shebang.
This actually works on Windows and Linux
#!python
On Linux, however, it is more usual to see the format of
#!/usr/bin/env python
The path to python in the scheduler's environment should be checked/set as well.
Steps
- First make sure python is in your user & system path. If exe is not in your path you have to add it and if your running Windows you must restart your PC for it to take effect.
- At the start of your python script it is recommended you set the shebang.
On Window has the format
#!python
Or on Linux that has the format of
#!/usr/bin/env python
An example script on a Windows would look like this and save with the extension .py, ie. test.py
#!python import os import sys if _name_ == "_main_": print("success") sys.exit(0)
Most of the agent plugins run on the integrate node.
The Action:
AgentPlugin screen would be defined like this for the location MSTGT, a Sqlserver target with the channel name chn1 calling the python script 'test.py' running on target Windows server with the path in my example @ C:Usershvrtestpythonscripts.
You should also run a test if you can run via command line like this on Windows to verify it works, for example
python <script fully pathed> C:usershvtestpython C:usershvrtestpythonscriptstest.py