Page 1 of 1
How to use "open process" for read and write?
Posted: Sat Apr 08, 2006 10:29 pm
by Garrett
Using Rev 2.6.1 on OS X
Greetings,
How do you properly syntax the open process command? I want to
read and write to the process. I tried the following:
Code: Select all
open process "/usr/bin/apphere" for read,write
But get this error "Handler: bad command" So I tried this:
Code: Select all
open process "/usr/bin/apphere" for read write
But get this error "Expression: missing factor" So I'm not sure how to
format the code correctly.
Any help, hints or suggestions is appreciated. Thanks,
-Garrett
Posted: Sat Apr 08, 2006 10:55 pm
by BvG
you should have tried:
Code: Select all
open process "/usr/bin/apphere" for update
The documentation is a bit confusing at first but the string at the top of each entry means:
open process appName [for [text|binary] {read | write | update | neither}]
open process (optional 1) for (optional 2) text or binary (end of optional 2) (one of these) read or write or update or neither (end of one of these) (end of optional 1)
Posted: Sat Apr 08, 2006 11:22 pm
by Garrett
Ahhhhhh...... Ok, I understand now.
Yeah, the example in the docs didn't really convey the possible uses.
Thanks a bunch!

-Garrett
How to use "open process" for read and write?
Posted: Wed Apr 12, 2006 5:07 pm
by pevensen
This is a related question. On Windows and Mac, what exactly does read from process and write to process do?
Does it read the stdout of the process and write to the stdin?
Does this mean that the launched app needs to use the stdio library?
I can see in a Unix context, this is how it would work, but with an OS X or Windows app, this seems a bit strange.
Posted: Wed Apr 12, 2006 7:06 pm
by 36degrees
They do as you would expect
In the case of OS X, since it is based on BSD UNIX, all applications implicitly have a stdin/stdout/stderr triplet just like on other Unices so it uses them. Of course, whether or not the application uses them is another matter. The OS X Console utility gives a GUI to see the output of any running applications.
You can also compile applications on OS X as UNIX processes - and these don't have the application bundle structure. As I recall, originally you couldn't call this style of process from Revolution on OS X - but I believe this was fixed in 2.6.1.
In the case of Windows, you can compile executables in either Console mode or GUI mode. The former is provided with the standard i/o handles by the OS, while the latter has to request them.
Posted: Wed Apr 12, 2006 7:50 pm
by pevensen
36degrees wrote:They do as you would expect
Now the big question is how about Java? Could you use it to pass data to a Java app?
I guess my original question was also what was needed for the launched process to receive data written to it and output data that is read. I think you confirmed that it uses stdio (stdin and stdout).
Thanks!
Posted: Thu Apr 13, 2006 4:52 pm
by 36degrees
The answer is: yes it could...
As I recall (although my memory might be faulty, its been a while since I wrote anything Java) the Java class library gives you access to the stdio/stdin/stderr handles through some static methods of the System class.
If the Java app is written to use those, then using open process on the java app (invoked using the appropriate command line arguments passed to the JVM) should work as you would like.