从Web应用程序运行命令

时间:2011-12-06 06:58:47

标签: web-applications command-line terminal batch-processing certificate-authority

我目前正在尝试从Web应用程序在命令行上运行命令。是否可以通过Web应用程序进行?

命令(在终端上):

cd ejbca/bin
./ejbca.sh batch

如何在按下按钮时在Web应用程序中运行它们?

2 个答案:

答案 0 :(得分:0)

如果我是你,我会让一个监听器与Web应用程序分开运行。当你按下按钮时,只需向听众发送一条消息,听众就会照常进行。

对于消息传递,您可能希望使用zeromq

答案 1 :(得分:0)

Java代码

Process proc = Runtime.getRuntime().exec("myshell.sh");

myshell.sh

#!/bin/bash
cd ejbca/bin
./ejbca.sh batch &

在你的example.jsp

<form method="get">
<input type="submit" name="example" value="Push Me" alt="example button">
<% 
    if ("Push Me".equals(request.getParameter("example"))) {
        Process proc = Runtime.getRuntime().exec("myshell.sh");
    }
%>
</form>
相关问题