shell command callback question
Mark Smith
mark at maseurope.net
Thu Apr 24 05:19:32 EDT 2008
Josh, there's a couple of ways to deal with this, but, as of 2.9, at
last we can read and write interactively to processes on OS X, so I
do things like this:
to encode an audio file with the flac command line encoder,
on flacEncode pInfile, pOutfile
put "flac" && pInfile && "-o" && pOutfile into tProc
open process tProc for update -- this starts the process working
-- this is often better done with a "send in time" handler and a
callback
-- but shows how it works
put 0 into tPercDone
repeat until tPercDone = 100
wait 250 millisecs with messages
read from process tProc until empty
put it into tProcOutput
...
statements to parse out the percentage complete from tProcOutput
...
put tPercDone
end repeat
close process tProc
end flacEncode
-------
Another option is to open "/bin/bash" as a process, so you can then
read and write to it as if it were the 'terminal' app.
best,
Mark
On 24 Apr 2008, at 05:33, Josh Mellicker wrote:
> When you execute a shell command in Terminal in OS X, (in
> appropriate cases) you get text back as the command executes. For
> example, when searching a hard drive, even though the entire
> process takes a while, at each moment it finds a matching file, it
> echoes it to the terminal, so you get a little feedback while
> you're waiting.
>
> However, in Revolution, when I execute a shell command, nothing is
> returned until the entire command is finishing executing, at which
> point I get all the echoed text at once.
>
> I am brand new at this and probably missing something obvious...
> how do you set up a callback so you get the echoed text in "real
> time"?
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list