cancel
Showing results for 
Search instead for 
Did you mean: 

Execute python script

AshokRpa
Level 2
Hi,

can you help me. how to execute python script using blueprism.

thanks and regards,
Ashok

------------------------------
Ashok Rpa
------------------------------
13 REPLIES 13

Hi Ashok,

If you wish to execute any python script on your machine, you can use the following DX exchange asset: Function for Blue Prism - Script Execution VBO - 1.0.0

Once you import this business object, provide these input and output parameters:

16301.png
Here is a sample execution of the business object:

16302.png

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Hi Devneet mohanty,

Thanks for your response.

I will try this method, when i run the program the output shows,  the script output is denied.

thanks and regards 
ashok


------------------------------
Ashok Rpa
------------------------------

Hi Ashok,

Can you type the below command in your cmd and let me know what you get:

python --version​

If you get some version number, then check where is your python.exe file once, if the file path is not provided correctly it might show an error. Also, can you post a screenshot of your parameters just to know what kind of data are you putting there as it will help us to know the issue more clearly.

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

StevenBrowning
Level 3

With Python and the script loaded on the individual VMs, I use Utility Environment VBO action Start Process Read Stderr and Stdout.
The process name will be "py" (or, perhaps "python" or "python3". Whichever works on your machine.)
The argument list will start with the path of the script (including the script name) and space delimited arguments required to run the script. 



------------------------------
Steven Browning
Application Development Specialist
Accenture
America/Chicago
------------------------------

Passing argument from blue prims to python script using Script Execution VBO | Digital Exchange (blueprism.com)

The above thread answered my question.

Hi Devneet,

Could you please share a code snippet of Python script that accepts input parameter from BluePrism and returns the result back to BP?
without parameters I can execute the script .

Thanks in advance

------------------------------
Roshini Syed
------------------------------

Hi Roshini,

I have created a workflow for your understanding as below:

16325.png

Here, ScriptEngineFilePath data item consists of the file path of 'python.exe' file on my machine whereas the ScriptFilePath data item consists of the folder location where my python script is located.

ScriptNameAndArguments data item consists of the name of the script along with each arguments separated by spaces.

NOTE: If the script name has spaces then you need to enclose it within double quotes and same also applies for the arguments. For example if the name of my script was Hello World.py and the argument was Hi everyone then I would be setting the value of ScriptNameAndArguments data item as follows: 

"Hello World.py" "Hi everyone"​


Now, if you have to make your python script accept arguments and return something out as well, you need to use the sys library to read arguments from command line which you can import in your script using the import sys keyword . Once the library has been imported, we can use the object sys.argv which represents the list of arguments being sent out via command line.

In my python script, I am sending out two number arguments which I need to add. Hence, to refer to each of these numbers I need to reach out to the index 1 and 2 of the list represented by sys.argv


sys.argv[1] and sys.argv[2] would correspond to the numbers that I am sending out. Now if I want to return any result from the script to the command line, I can simply print the result out. Hence, in order to return the sum of my arguments, I can simply use a command like:

print(sys.argv[1] + sys.argv[2])

So my python script overall will look like this:

import sys

a = int(sys.argv[1])
b = int(sys.argv[2])

print(a+b)​


16326.png

If you compare the data items being sent against how manually we do it, you would get a mapping like below:

16327.png

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Hi, Devneet!

Please tell me, can we execute the script without arguments?

For example
ScriptNameAndArguments:   "main.py"

------------------------------
Eugene Ivaniv
------------------------------

Hi Eugene,

16340.png
Here where I have indicated Script File Name & Arguments, there just pass the script name ending with .py extension that's all. If let say I wont have any argument written in my above shown example then ideally my command would look like this:

"C:\Users\DevneetMohanty\AppData\Local\Programs\Python\Python310\python.exe" "addNumbers.py"



------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Nice. Has someone made actions to execute python / nodejs script not from file but from data item?

------------------------------
Tomas Kochan
------------------------------