长进程shell脚本cgi?

发布于 2024-09-29 19:36:05 字数 825 浏览 1 评论 0原文

我有一个 CGI shell 脚本,用于下载软件包列表。它会打印有关该进程的一些信息,然后开始运行它。完成后,它会显示作业的结果。

它工作得很好,但是,在该过程完成之前,浏览器上不会显示任何内容。有没有某种方法可以告诉浏览器加载已有的信息并保持不变?

例如:

#!/bin/bash
echo -e "Content-type: text/html\n\n"

wgetCom="wget --quiet"

echo "<html><body><pre>"    

    echo    "Downloding autoconf"
    $wgetCom http://people.redhat.com/eblake/autoconf/autoconf-2.68.tar.bz2

    echo    "Downloding automake"
    $wgetCom http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.bz2

    echo    "Downloding bash"
    $wgetCom http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz

    echo    "Downloding binutils"
    $wgetCom http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.bz2

    echo "Download is Done"


echo "</pre></body></html>"

我需要的是在处理 shell 脚本时显示 echo。

任何帮助将不胜感激。

I have a CGI shell script that download a list of packages. And it prints some information about the process and then starts running it. When complete, it shows the result of the job.

It works perfectly, however, on the browser doesn't show any thing until after the process is complete. Is there some way that tell the browser to load the information it already has and hold tight?

for example :

#!/bin/bash
echo -e "Content-type: text/html\n\n"

wgetCom="wget --quiet"

echo "<html><body><pre>"    

    echo    "Downloding autoconf"
    $wgetCom http://people.redhat.com/eblake/autoconf/autoconf-2.68.tar.bz2

    echo    "Downloding automake"
    $wgetCom http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.bz2

    echo    "Downloding bash"
    $wgetCom http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz

    echo    "Downloding binutils"
    $wgetCom http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.bz2

    echo "Download is Done"


echo "</pre></body></html>"

what i need is to show the echo's while process the shell script.

Any help would be much appreciated.

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

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

发布评论

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

评论(1

朮生 2024-10-06 19:36:05

您要求的是关闭输出缓冲。我不确定 bash 是否会这样做或如何禁用它,但我确实知道如果 apache 配置为压缩输出,则它不会缓冲。添加包含以下内容的 .htaccess 文件:

BrowserMatch Mozilla no-gzip

看看它是否神奇地开始工作。如果没有,请回到绘图板。

What you're asking for is turning off output buffering. I'm not sure if bash does at all or how to disable it, but I do know that apache will not buffer if it is configured to compress the output. Add a .htaccess file with this content:

BrowserMatch Mozilla no-gzip

And see if it magically starts working. If not, back to the drawing board.

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