I am doing a project for that need to trigger python scripts from pega RPA studio,
is there any way to call a python script from RPA studio?
@JoelPrakashJ2907You may do so using the Process.Start method. You can do this in an automation if you may need to use breakpoints or other debugging tools, or inside a script would work as well. The code is down below the screenshot for easy copying and pasting. If you have a sample script to test with, please post, and I can validate that this works as I have not had any opportunity to execute a python script in an automation, but from my research, this code should work.
To create the ProcessStartInfo, I first added the StartProcess method to the automation and then right-clicked on the blue dot for startInfo and selected “create instance”. You can then drag the blue dot out of the StartProcess method to get to the ReadToEnd and WaitForExit methods.
public string RunPythonScript(string fileName, string pathToPythonExe)
{
//fileName = @“C:\sample_script.py”;
//pathToPythonExe = @“C:\Python27\python.exe”
Process proc = new Process();
proc.StartInfo = new ProcessStartInfo(pathToPythonExe, fileName)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
return output;
}
@ThomasSasnett The automation (and script) works with a simple “Hello world” python script.
