Perl accepts the script through STDIN. After pressing CTRL-D, perl knows "End Script". After that, the script is executed.
Now my question is: I will do this using Java.
- Perl Open Process
- Copy script to STDIN Perl-Process
- HOW I SIGNED PERCEL CRTL-D WITHOUT CLOSING THE FLOW (from inside java)
- Send some input to Script
- get some output from script.
proc = Runtime.getRuntime().exec("perl", env);
commandChannel = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream()));
responseChannel = new BufferedReader(new InputStreamReader(proc.getInputStream()));
InputStreamReader mymacro = new InputStreamReader(getClass().getResourceAsStream("macro.perl"));
char[] b = new char[1024];
int read;
try
{
while ((read = mymacro.read(b)) != -1)
{
commandChannel.write(b, 0, read);
}
commandChannel.flush();
PERL IS WAITING FOR END OF SCRIPT; ??
} ...
source
share