Perl accepts a scipt via STDIN. After pressing CTRL-D perl knows the "End of Script". After doing so, the script is executed.
Now my question: I wand to do that from Java.
- Open Process Perl
- Copy Script into STDIN of Perl-Process
- HOW DO I SIGNAL PERL THE CRTL-D WITHOUT CLOSING THE STREAM (from within java)
- Send some input to the 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; ??
} ...
__END__to Perl rather than closing STDIN? (or^Dor^Z-- see perldoc.perl.org/perldata.html#Special-Literals )