Shell 脚本 - 管道和重定向
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这有效:
This works:
您可以不用命名管道。 您提到的 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.