Thursday, June 22, 2017

#1 2013-03-25 03:49:03 am

Registered: 2013-02-27
Posts: 6

Feeding progress bar with do shell script output

Hi there,
I am using a do shell script that runs qt_export, to export quicktime movies to wmv. I'd like to have some kind of progress info in my main window app.

Most of the options I've found here are focused on batch processes, which is not the case. And on the other hand all that I found regarding single processes (not batches) are indeterminate progress bars.

Qt_export outputs a progress live feedback when run in Terminal, like this:

# progress: (013:001)  18.67% --> test.wmv
# progress: (013:001)  21.33% --> test.wmv
# progress: (013:001)  24.00% --> test.wmv
# progress: (013:001)  26.67% --> test.wmv
# progress: (013:001)  29.33% --> test.wmv

But when I do shell script, I don't get it in "real-time" but when the process is finished. How could I write that to a file and read it to feed my progress bar?




#2 2013-03-27 02:21:48 am

Registered: 2013-02-27
Posts: 6

Re: Feeding progress bar with do shell script output

Self reply smile

In the same do shell script command line, I write a file with the output of the shell but as a process in the background:


do shell script "any_commands_you_need > path/myFile.txt 2>&1 &"

Then I load a part of the output in myFile.txt (the percentage number) and pass it to a indicator progress bar in the IB. One thing it took me a while is to realize that to make the progress bar update continuously a progressBar's setUsesThreadedAnimation_(true) need to be added in the script, somewhere before the progressBar's setDoubleValue_(percentageNumber).



Board footer

Powered by FluxBB

[ Generated in 0.108 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)