I have a java architecture which accepts linux command as a string, which run on a remote linux machine and returns the output.
The command as a string is working for these single commands such as
cat filename
grep <string> filename
But the command is not executing properly when I pass it a with pipe such as this one
cat filename | grep string
The command is being sent as a java string. I tried to pipe with \\
(like this \\|
) but with no success.
Any possible solution ?
Ps: The architecture returns the output as a string file. In the case where I say the command is not working i see empty string as an output
The pipe character is a "shell thing" - never going to work within the command executed by a single process.
Consider connecting the output stream of the first command to the input stream of a separate process for the second command.