You cannot use the PIPE inside the Runtime.getRuntime().exec()
as you do in your example. PIPE is part of the shell.
You could do either
- Put your command to a shell script and execute that shell script with
.exec()
or -
You can do something similar to the following
String[] cmd = { "/bin/bash", "-c", "echo password | python script.py '" + packet.toString() + "'" }; Runtime.getRuntime().exec(cmd);