关于使用哪种语言的建议

发布于 2024-09-27 02:29:27 字数 425 浏览 1 评论 0原文

我正在尝试创建一个将从系统获取输入的网络应用程序。

该应用程序应该做的是监听某些 shell 脚本执行时发生的情况并通过 web 报告状态。

一个例子:

  • 我正在使用 shell 脚本复制数千条记录,当它仍在执行时,我想将脚本的当前状态传递到 Web 界面。从 shell 脚本方面,我可以回显类似“正在复制文件,请等待其完成”之类的内容。

从 shell 端使用哪种编程语言是将其传递到 Web 界面的最简单方法?我打算使用 JSP/JAVA 进行网络。

这是思考这个问题的正确方式吗?欢迎提出每一个建议

编辑

类似http://nodejs.org/之类的东西对这?

I'm trying to create a web application which will get input from system.

What this application should do is to listen what happens when some shell scripts are executing and reporting the status trough web.

An example :

  • I'm copying thousands of records with shell script, and while this is still executing I'd like pass the current status of the script to the web interface. From shell script side I could echo something like "The files are being copied please wait for it to finnish".

Using which programming language from shell side would be the easiest way to pass this to the web interface? I intended to use JSP/JAVA for web.

Is this even the right way to think about this? Every suggestion is welcome

EDIT

Would something like http://nodejs.org/ be useful for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

静若繁花 2024-10-04 02:29:28

我会使用命名管道(FIFO)来代替。您只需将输出写入管道并让应用程序读取它。我不确定是否还有其他方法可以获得比这更活跃的系统。

我推荐 Perl 作为后端。

编辑:

命名管道是 UNIX 上的一种特殊类型的文件。缩写 FIFO 代表“先进先出”。在 LINUX Journal 上,您可以找到一篇有趣的有关命名管道的文章

Perl 是一种非常强大的脚本语言,具有许多即用型模块,您可以在 http://cpan.org。您可以在此处找到一些关于如何操作的答案/从哪里开始学习 Perl。

I'd use a named pipe (FIFO) instead. You simply write your output to the pipe and let the application read it. I'm not sure if there is any other way to get a more live system than this.

I'd recommend Perl as the back-end.

EDIT:

named pipes are a special type of files on UNIX. The abbreviation FIFO stands for "First In First Out". On LINUX Journal you can find an interesting read about named pipes.

Perl is a very powerful scripting language with many ready-to-use modules which you can find on http://cpan.org. You can find some answers here on SO about how/where to start learning Perl.

梦里南柯 2024-10-04 02:29:28

应用程序的 Web 部分可以轻松读取文件或数据库,因此您只需确保 shell 脚本输出一些内容以供 Java 代码更新。

例如,如果您像这样运行 shell 脚本

./myscript.sh > mylog.log

那么在您的 Java 代码中(请注意,您的 JSP 中不应该有逻辑),您可以读入该文件以确定更新的状态,并将结果输出到您的 JSP 。

最好从数据库读取数据,但这需要您更改 shell 脚本以将数据输出到数据库。

The Web part of your application can easily read a file or a database, so you just need to make sure that your shell scripts are outputting something for your Java code to update.

For example, if you run your shell script like this

./myscript.sh > mylog.log

Then in your Java code (note that you should not have logic in your JSP), you can read in the file to determine the status of the update, and output the result to your JSP.

It would be better to read the data in from a database, but that would involve you changing your shell script to output the data to a database.

哭了丶谁疼 2024-10-04 02:29:28

您可以将 shell 脚本输出放入服务器上的某个存储中。并在网页上使用 AJAX 来轮询服务器并获取从该存储到页面的更新。

如果您决定使用 JSF 来创建网页,我可以推荐 ajax2jsf 库中的“a4j:poll”组件。它非常简单明了。从网页轮询服务器的非常简单的方法。

You could put shell script output to some storage on server. And use AJAX on the web page to poll the server and get updates from that storage to the page.

If you will decide to use JSF for web page creation I can recommend "a4j:poll" component from ajax2jsf library. It is very simple and straightforward. Very easy way to poll server from the web page.

深海夜未眠 2024-10-04 02:29:28

写入日志文件将是最简单的解决方案。在编程中,简单往往意味着好。

如果您确实需要非常快速/实时的系统,您可能应该将这些日志作为数据库。

至于语言,使用你最喜欢的。它们都支持 SQLite,包括 bash。

Writing to log file would be the simplest solution. And in programming, simple often means good.

If you really need very fast/realtime system, you should probably make these logs a database.

As for language, use what you like best. They all do support SQLite, including bash.

一页 2024-10-04 02:29:28

如果我正确理解您的问题,您希望在客户端计算机上显示一个网页,报告服务器计算机上长时间运行的任务的状态。如果是这种情况,那么您需要关注 AJAX IMO。

据我所知,最简单、最容易理解的 AJAX 实现是 Apache Wicket

If I understand your question correctly you want to display a web page on a client machine that reports the status of a long running task on a server machine. If that is the case then you need to focus on something called AJAX IMO.

For what it is worth the simplest and easiest to understand implementation of AJAX that I know of is Apache Wicket.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文