In a little app, I'm running a terminal command, drutil erase. I'm using a NSTask
. When you execute this command in Terminal, it will show you an ASCII progress bar which is continuously updated. However, I'm not able to read this information in my outputpipe or errorpipe using my NSTask
. Does anyone has an idea how to to obtain the percentage of drutil's process?
Asked
Active
Viewed 567 times
2

Justin Boo
- 10,132
- 8
- 50
- 71
1 Answers
1
Using asynctask.m you can print the progress indicator of curl to stderr in Terminal.app!
This approach should work for "drutil erase" as well.
// asynctask.m code is available at:
// http://www.cocoadev.com/index.pl?NSPipe
fprintf(stderr, "\r\033[0K%s", [s UTF8String]);
Perhaps yet another way to print an ASCII progress bar via NSTask would be to combine the fprintf line above with PseudoTTY.app, which uses pseudo-ttys instead of pipes for line-buffered inter-process streams.

carl
- 11
- 1