Problem calling piped perl routine

I am calling few perl routines from my Java program (in an Unix environment) using Runtime process call. While most get executed normally, I am facing problem with routines that get parameters as output from other routine i.e. routines that use Piping, ex:

When run directly from command line it works well. But when called through my program only the routine1 gets exceuted printing its output at command line, the second routine doesn't get the output from first and does not execute. I am not aware of and cannot change the perl routines.

Implementing the piping yourself would be interesting. Start two processes, start a thread that reads the stdout of the first and writes to the stdin of the second. It would sure be nicer if you could get the piping going outside of Java, tho.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

I finally found the solution here. As the article says, Runtime.exec invokes actual executable binary programs. Syntax such as pipe and > are part of a particular command processor, and are only understood by that processor. So the command preceding the pipe is executed, but the rest of the shell command is not.