Read from process
Mike Bonner
bonnmike at gmail.com
Wed Mar 28 19:35:33 EDT 2012
Sorry for posting and falling off the earth. A bit sick today but will try
and give the gist of a send in time loop. This is just off the top of my
head and as always there are probably better ways to do this (also as I
mentioned before, not sure which forms of read will block and which won't
so your mileage may vary depending on need)
command startProcess
## code to connect to the process
open process "myprocess" for update
## check for errors opening the process, if no errors then
set the cRunning of this card to true -- a method to break the loop, set to
false to stop the loop
readloop -- handler to do the read
end startProcess
command readloop
if the the cRunning of this card then
read from process "myProcess" until empty
if it is not empty then
#do whatever you want with the resulting read.
#if the end line is read, close process set the cRunning of this card to
false
end if
send "readloop" to me in 1 tick
end if
end readloop
On Wed, Mar 28, 2012 at 4:19 PM, Glen Bojsza <gbojsza at gmail.com> wrote:
> My first test has come back fairly well.
>
> I missed some of the initial lines of output but got all the remaining
> lines.
>
> I broke out of the loop no problem with the unique output line... when it
> was seen in the output I exited the repeat.
>
> So the first issue I would like to solve is either have the scrolling field
> show the latest output ... how can you have the field show the last ten
> lines?
>
> Optionally, try to figure out a send in time and see if it frees the
> user... if it does then this would be the better solution.
>
> Glen
>
> On Wed, Mar 28, 2012 at 4:08 PM, Bob Sneidar <bobs at twft.com> wrote:
>
> > One method I have heard of is to redirect output to a text file, then
> open
> > the file for read and read from the file every so often in a repeat loop.
> > You still need to know when the process has ended so you can break out of
> > the loop.
> >
> > Bob
> >
> >
> > On Mar 28, 2012, at 2:39 PM, Glen Bojsza wrote:
> >
> > > The documentation seems slightly confusing (to me).
> > >
> > > On Linux I want to open a process for update, then write the command to
> > be
> > > executed and then read from the process and fill the output to a field.
> > >
> > > The command takes anywhere from 1 minute to 8 minutes to execute and
> > while
> > > it is running it outputs the various stages and results it currently
> has
> > > completed.
> > >
> > > In the terminal window if I just do the command line it produces
> anywhere
> > > between 20 to 100 lines of output where the final line has a unique
> > output
> > > acknowledging that it has completed.
> > >
> > > How should I be writing my read from process?
> > >
> > > I assume that this should be done inside a repeat forever loop where
> you
> > > can trap the mouseclick to exit or check for the unique output line
> from
> > > the read process to exit.
> > >
> > > I can't seem to any output from the read statement?
> > >
> > > Finally, is there a way to make this non blocking (ie let it run and
> > update
> > > the field while the user moves on to something else)?
> > >
> > > thanks,
> > >
> > > Glen
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list