Using open process instead of shell

Mike Bonner bonnmike at gmail.com
Sun Dec 24 19:56:40 EST 2017


Off the top of my head, untested (no mac available)

on executeProcess pData
    put whereAmI() into a; set the defaultFolder to a
-- I'd bipass this
--    get "file:xprocess.bat"
--    put pData into URL it


    open process  "file:xprocess.bat"  for text write
-- this part, if you want to use a shell file (bat?) you a) have to make
sure its set to executable
-- b) You'd want to prepend #!/bin/sh so that it knows what shell to use on
execution (or use sh xprocess.bat as your command)
-- c ) Don't think it will work using the URL form  It should be -- open
process "xprocess.bat" for text read
-- text read because you want to read the output (or update if you need to
send additional commands interactive)

--Since you want to be able to check progress you'll need to start a read
loop too..
-- if it were me, i'd just call openprocess with your known working command
line
open process pData for text read with message

-- start read loop
send "monitorslave pdata" to me in 50 millisec

close executeProcess


command monitorslave pProcess
-- read loop.. DO what you need to check progress here..
read from process pProcess until empty

-- Somewhere in here you'll need to determine if the process is done, close
it, and exit without looping again
-- or update status and loop again

    send monitorslave pProcess to me in 50 millisec -- loop again if not
done
end monitorslave


if you want to use the same slave loop for multiple processes, you'll of
course have to parse the url to know how to handle the output
(Or just make a custom slave loop for each of your 3 executables)
I also don't know if you will actually need to close the process, or if it
will self close when done.  As mark pointed out, you can look at
openprocesses() to see whats currently running.



On Sun, Dec 24, 2017 at 4:30 PM, Mark Wieder via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 12/24/2017 02:05 PM, Stephen Barncard via use-livecode wrote:
>
> ​ Does someone out there have a clear example of what I am looking for,
>> using a UNIX  executable  through *open process​ *?
>>
>> 1.    call the function  with parameters
>> 2.     allow livecode scripts to continue
>> 3.     continuously monitor and display data returned by that function
>>
>>
>>   thank you all so much for any and all information,
>>
>
> check out the openProcesses function to see what's still in play
> here's an example from the 'close process' doc:
>
> close process myProcess
> wait until myProcess is not among the lines of the openProcesses
> open process myProcess
>
>
> --
>  Mark Wieder
>  ahsoftware at gmail.com
>
>
> _______________________________________________
> 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