4

I am currently working on a pre-flight-check script for the Apache PLC4X project. There I check the existence of required third party tools and their versions.

If I run "python --version" on the commandline, I get a nice response.

However if I run it in Groovy:

print "Detecting Python version: "
def output = ("python --version").execute().text

I just get an empty string. All the other tools don't show this behavior. All others have the console output in "output".

How can I do the check I want to do? What am I doing wrong?

Justin Mclean
  • 1,615
  • 13
  • 14
Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
  • 1
    Did you mean to `println output`? You’ve stored the result to a variable so I wouldn’t expect anything to stdout – thehole May 23 '19 at 16:12
  • @Sheldore it's Groovy, as mentioned in the title, the tags, and several times in the body :D – Adam Smith May 23 '19 at 16:13
  • @AdamSmith: Sorry for my negligence. It was tagged python so I thought it still has to follow basic syntax rules – Sheldore May 23 '19 at 16:16
  • It's obviously only part of the script ... and yes: I's written in Groovy: See the full script here: https://github.com/apache/plc4x/blob/develop/src/main/script/prerequisiteCheck.groovy – Christofer Dutz May 24 '19 at 08:33

1 Answers1

2

Don't assume everything you see on the terminal comes via standard output.

Informational messages are frequently sent to standard error instead, to avoid having them get caught in any processing pipelines (which was why the two channels were created way back in the early UNIX days).

holdenweb
  • 33,305
  • 7
  • 57
  • 77