2

We have been using a piece of code for quite a while now, and it stopped working. The code is effectively: Runtime.getRuntime.exec(new String[] { "sh", "-c", "/opt/mycommand myparam | sed -ne '/searchstring/p;/searchstring2/q' | tail -1" }); We are in the process of upgrading from Websphere 8.5 to Websphere 9.0 and picked up a new JDK. I found a number of answers (e.g. Why does Runtime.exec(String) work for some but not all commands?) and articles (e.g. https://blogs.oracle.com/thejavatutorials/jdk-7u25:-solutions-to-issues-caused-by-changes-to-runtimeexec) that help indicate ways to rewrite the code to work using processBuilder. What I would like to find is the specific thing that changed that might have caused this change. Is there a new Java or IBM JDK version that deletes the jdk.lang.Process.allowAmbigousCommands as a default setting, or did the tag get the spelling corrected without keeping the old one for backward compatibility, or what?

The code used to work as "/opt/mycommand myparam" | sed -ne '/searchstring/p;/searchstring2/q' | tail -1 but now fails to pass myparam to mycommand and I get an error from mycommand that it needs a parameter.

I've converted the code to use a processBuilder successfully, but I'm curious about the underlying reason for the problem.

Sinc
  • 553
  • 1
  • 8
  • 31

0 Answers0