tags:

views:

46

answers:

1

Consider the following script:

println "ls -l".execute().text

Why do I get the following error when running with JDK 1.6.0_14?

Caught: java.io.IOException: Cannot run program "ls": java.io.IOException: error=40, Too many levels of symbolic links
        at a.run(a.groovy:2)

When run with JDK 1.5.0_08 I get the expected output. This, by the way, is one of the examples on the Groovy Process management page. A simple solution seems to be to run it within a shell:

println ["/bin/sh", "-c", "ls -l"].execute.text

But this shouldn't be necessary, no?

+1  A: 

Have you tried this?

println "/bin/ls -l".execute().text
daveb
That seems to work, though it doesn't explain the difference between JDK5 and JDK6.
balor123