繁体   English   中英

在每个实例中缓冲输出到前端的后台脚本

[英]Buffering the background scripts output to the front end at each instance

我正在开发一个Web应用程序,其中使用Java作为前端,使用Shell脚本作为后端。 我需要在Shell脚本中处理很多文件,让我假设我需要在Shell脚本中处理1000个文件。 我正在使用Java中的以下代码

for(i from 1..1000)
{
       Call shell script to process file i
}

通常,在shell脚本中,我正在做一些处理逻辑,并将o / p存储在本地文件中(然后可以从Java中访问它)。

My requirement is, for everytime the shell script being called, an output is generated to a file. so as an when the control from shell script to java, I have to process it and display it in the front end. But the for loop should not break. It has to carry on with as it is but some front end work of displaying this file should also take place.

我尝试搜索有关此内容,并且获得的建议是为此使用AJAX和长轮询以及线程。 你们可以就此分享一些想法吗? 谢谢。

这也可以通过websockets完成。 例如,您可以每100个发回信息。另外,还可以使用Google“ Comet”或“ Reverse Ajax”(特别是对于较旧的浏览器支持)。

确实,您可能想要查看Socket.Io或其他语言/环境的相应框架。

如今,许多用户正在运行具有Web套接字支持的HTML 5浏览器,因此,根据受众群体,您不必担心打开长轮询连接的麻烦。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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