Shell 脚本 - 管道和重定向

发布于 2024-07-26 04:59:58 字数 611 浏览 4 评论 0原文

我使用 CocoaDialog 在执行下载脚本期间提供一些反馈。 我希望在我们进行命令操作时显示一个不确定的进度条。 这可以通过在操作期间将文本传送到 CocoaDialog 来实现。

我想 可以使用一个命令来完成此操作,如下所示:

exec("curl -O $PATH_DOWNLOAD > $PATH_COCOADIALOG progressbar --indeterminate");

但这不起作用。

下面是一个更深入的 shell 脚本,它以不同的方式执行此操作:

http://cocoadialog .sourceforge.net/examples/progressbar.sh.txt

任何提示或技巧表示赞赏。

谢谢,
马特

I'm using CocoaDialog to present some feedback during execution of a download script. I wish to present an indeterminate progress bar whilst command operation us taking place. This is possible by piping text to CocoaDialog for the duration of the operation.

http://cocoadialog.sourceforge.net/documentation.html#progressbar_control

I thought I could do it using one command, as follows:

exec("curl -O $PATH_DOWNLOAD > $PATH_COCOADIALOG progressbar --indeterminate");

But this does not work.

Here's a more in-depth shell script that does it a different way:

http://cocoadialog.sourceforge.net/examples/progressbar.sh.txt

Any hints or tips appreciated.

Thanks,
matt

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

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

发布评论

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

评论(2

爱*していゐ 2024-08-02 04:59:58

这有效:

curl -O $PATH_DOWNLOAD 2>&1 | $PATH_COCOADIALOG progressbar --indeterminate

This works:

curl -O $PATH_DOWNLOAD 2>&1 | $PATH_COCOADIALOG progressbar --indeterminate
梦幻的心爱 2024-08-02 04:59:58

您可以不用命名管道。 您提到的 popen/pclose 允许您通过匿名与进程进行通信。 仅在处理不相关(父/子)进程时,命名管道才真正必要。

像这样:

$pipe = popen("| nameOfTheExecuable");
写($pipe, "某事");
....
pclose($管道);

$pipe 是可用于写入子进程的标准输入的句柄。

You can do without named pipe. popen/pclose you mentioned allows you to communicate with the process through anonymous one. Named pipes really necessary only when dealing with non-related (parent/child) processes.

Like so:

$pipe = popen("| nameOfTheExecuable");
write($pipe, "Something");
....
pclose($pipe);

$pipe is the handle you can use to write to the standard input of your sub-process.

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