Perl通过STDIN接受一个scipt.按下CTRL-D后,perl知道"脚本结束".执行此操作后,将执行该脚本.
现在我的问题是:我想从Java那里做到这一点.
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; ??
} ...
Run Code Online (Sandbox Code Playgroud)