1

In my Katalon project (running on Windoes OS), I like to run an external python program.

I was looking at several examples of how to execute an external program from a Java or Groovy program.

The problem is that no matter what program I try to run (the python script or even a simple cd command), I get the following error from Katalon-Studio:

[ERROR]  - Test Cases/CallPython FAILED because (of) java.io.IOException: Cannot run program "cd": CreateProcess error=2, The system cannot find the file specified

Here are some of the options I tried:

Groovy:

println "python myp.py".execute().text
println "cd".execute().text

Java

Process p = Runtime.getRuntime().exec("python myp.py");
String[] cmd = ["python", "myp.py"];
Process p = Runtime.getRuntime().exec(cmd);
Process p = Runtime.getRuntime().exec("cd");
Laurent LAPORTE
  • 21,958
  • 6
  • 58
  • 103
riorio
  • 6,500
  • 7
  • 47
  • 100

1 Answers1

0

If everything has good HOME_PATH this code should help

ProcessBuilder pb = new ProcessBuilder("cmd", "python myp.py")
Process process = pb.start()
siranen
  • 374
  • 1
  • 11