动态创建控制台类型文本动画

时间:2015-12-18 19:37:48

标签: jquery coldfusion

我在ColdFusion中创建一个webapp,它将在服务器上执行bash脚本。我想要做的是动态(实时)输出网页中的BASH输出本身,或者根据检查作业的状态输出我自己的状态文本。例如,如果我正在运行一个bash脚本并且它成功完成,我想把它放在网站上,但输出如下:

Starting test.sh....COMPLETE.

我希望它暂停在....并等待我检查输出(或日志文件),然后写入COMPLETE或FAILED,具体取决于日志告诉我的内容。有没有办法做到这一点?如果不清楚,我道歉。

1 个答案:

答案 0 :(得分:0)

我建议让Java做这样的事情:

<cfscript>
    p = createObject("java", "java.lang.Runtime").getRuntime().exec("/tmp/foo.sh");
    reader = createObject("java", "java.io.BufferedReader").init(createObject("java", "java.io.InputStreamReader").init(p.getInputStream()));

    line = reader.readLine();

    while (not isNull(line))
    {
        writeOutput(line);
        writeOutput("<br />");
        getPageContext().getOut().flush();
        line = reader.readLine();
    }

    writeOutput("<hr />");
    writeOutput("done!");
</cfscript>

shell脚本如下所示:

#!/bin/bash
echo -e "one"
sleep 1
echo -e "two"
sleep 1
echo -e "three"
sleep 1
echo -e "four"
sleep 1
echo -e "five"
相关问题