Page 1 of 1
Open Process command
Posted: Fri Apr 07, 2017 4:45 pm
by rblackmore245
Can someone post an example script of how to read from this ?
For example I want to be able to use a command line application in windows and get the console strout output and display this in a field just like you would see in the command line window.
E.G a ping -t
www.google.co.uk
There is hardly any documentation on how to read a text output from this.
Re: Open Process command
Posted: Fri Apr 07, 2017 4:54 pm
by Klaus
Hi rblackmore245,
just tried it at home (on my Mac, but the same applies to Windows!) and had success with this script:
Code: Select all
on mouseUp
get shell("ping -t 2 www.google.co.uk")
put IT & CR & the result into fld 1
end mouseUp
So I think THE RESULT contains the output of the SHELL command.
Hope that helps!
Best
Klaus
Re: Open Process command
Posted: Mon Apr 10, 2017 9:53 am
by rblackmore245
Thanks for your reply.
Yes I have used the shell command before but looking for something that will give a constant output from a process which I believe this function will work.
http://livecode.wikia.com/wiki/Open_process
I am able to get the process to open but unable to get the result or poll for the result at an interval.
Re: Open Process command
Posted: Mon Apr 10, 2017 10:49 am
by Klaus
Ah, I see, but that stuff is unfortunalely over my head.

Re: Open Process command
Posted: Mon Apr 10, 2017 10:51 am
by MaxV
Hi,
you can't pass parameter with
open process, so you have to write the process with options on a file and launch it.
Here a working example on windows:
To launch the process, double check that you are in a writing folder (using defaultFolder), and then:
Code: Select all
put "ping -t www.google.co.uk" into URL "file:myProcess.bat"
open process "myProcess.bat" for text read
to read 5 lines of the output:
Code: Select all
read from process "myProcess.bat" for 5 lines
put it into field "process output"
to close process:
Re: Open Process command
Posted: Mon Apr 10, 2017 2:58 pm
by rblackmore245
Thank you that works great but is there anyway to make it work asynchronous so it does not wait for the expected output and pause the stack and pause all scripts
Re: Open Process command
Posted: Mon Apr 10, 2017 3:20 pm
by FourthWorld
The "open process" command can be for "read", "write", "both" or "neither", IIRC "neither" will spawn the process and return immediately without waiting for a result.
Re: Open Process command
Posted: Mon Apr 10, 2017 5:20 pm
by MaxV
rblackmore245 wrote:Thank you that works great but is there anyway to make it work asynchronous so it does not wait for the expected output and pause the stack and pause all scripts
The example code:
Code: Select all
put "ping -t www.google.co.uk" into URL "file:myProcess.bat"
open process "myProcess.bat" for text read
doesn't block the script, you can do else.
When you want to see what happen, then you use the
read from process code.