Open Process command
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Open Process command
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.
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
Hi rblackmore245,
just tried it at home (on my Mac, but the same applies to Windows!) and had success with this script:
So I think THE RESULT contains the output of the SHELL command.
Hope that helps!
Best
Klaus
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
Hope that helps!
Best
Klaus
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Re: Open Process command
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.
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
Ah, I see, but that stuff is unfortunalely over my head.
Re: Open Process command
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:
to read 5 lines of the output:
to close process:
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
Code: Select all
read from process "myProcess.bat" for 5 lines
put it into field "process output"
Code: Select all
close process "myProcess.bat"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- Posts: 67
- Joined: Fri Jun 12, 2015 9:42 am
Re: Open Process command
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
-
- VIP Livecode Opensource Backer
- Posts: 9857
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Open Process command
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Open Process command
The example code: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
Code: Select all
put "ping -t www.google.co.uk" into URL "file:myProcess.bat"
open process "myProcess.bat" for text read
When you want to see what happen, then you use the read from process code.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w