简体   繁体   中英

Pipe character is being skipped in java string

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM