What are the possibility to execute an external program from Squeak? And portable for sebveral OS host? The programm I want to execute will do so briefly.
I read aboud OSProcess, CommandShell but I am not sure where it is best to look at.
Hilaire
On Thu, Jun 14, 2007 at 05:53:24PM +0200, Hilaire Fernandes wrote:
What are the possibility to execute an external program from Squeak? And portable for sebveral OS host? The programm I want to execute will do so briefly.
I read aboud OSProcess, CommandShell but I am not sure where it is best to look at.
Hilaire,
OSProcess and CommandShell work well for doing this on Unix, and I think that most things work well on Mac OS X also. It is not really useful for Windows, and does not work at all on RiscOS.
FFI is very good for running programs on Windows, and also does many things in a cross-platform manner.
There is not (yet) a general cross-platform solution. If you can explain what kind of program you are trying to run, maybe I can give a suggestion.
Dave
David T. Lewis a écrit :
There is not (yet) a general cross-platform solution. If you can explain what kind of program you are trying to run, maybe I can give a suggestion.
Thanks for for your feedback.
I want to run the espeak program for speech synthesis. Basically I just want to run a command like:
espeak "Speech a few word"
or
espeak "Speech a few word" -w output.wav
In the first case, it may be better if the command is executed in non blocking mode for Squeak. In the second mode a blocking mode may be better, or even semaphore will be helpful.
Hilaire
On Fri, Jun 15, 2007 at 08:59:46AM +0200, Hilaire Fernandes wrote:
David T. Lewis a ?crit :
There is not (yet) a general cross-platform solution. If you can explain what kind of program you are trying to run, maybe I can give a suggestion.
Thanks for for your feedback.
I want to run the espeak program for speech synthesis. Basically I just want to run a command like:
espeak "Speech a few word"
or
espeak "Speech a few word" -w output.wav
In the first case, it may be better if the command is executed in non blocking mode for Squeak. In the second mode a blocking mode may be better, or even semaphore will be helpful.
Hilaire,
OSProcess will work well for this. When you run an external program, it gives you a "process proxy" in Squeak the keeps track of the run state of the external program, as well as exit status after the program completes. However, as I said this is not cross-platform. It will work on Linux and Unix, and will work on Mac OSX if you install the plugin from unix/linux. It will also work on Windows, but only if you build your own VM and modify some of the Windows platform source, so this is definitely not for beginners ;) So on, Windows, it is best to use FFI (but I don't think you can have a blocking mode with this).
HTH,
Dave
And what about OSCommand on Windows ?
Hilaire
David T. Lewis a écrit :
On Fri, Jun 15, 2007 at 08:59:46AM +0200, Hilaire Fernandes wrote:
David T. Lewis a ?crit :
There is not (yet) a general cross-platform solution. If you can explain what kind of program you are trying to run, maybe I can give a suggestion.
Thanks for for your feedback.
I want to run the espeak program for speech synthesis. Basically I just want to run a command like:
espeak "Speech a few word"
or
espeak "Speech a few word" -w output.wav
In the first case, it may be better if the command is executed in non blocking mode for Squeak. In the second mode a blocking mode may be better, or even semaphore will be helpful.
Hilaire,
OSProcess will work well for this. When you run an external program, it gives you a "process proxy" in Squeak the keeps track of the run state of the external program, as well as exit status after the program completes. However, as I said this is not cross-platform. It will work on Linux and Unix, and will work on Mac OSX if you install the plugin from unix/linux. It will also work on Windows, but only if you build your own VM and modify some of the Windows platform source, so this is definitely not for beginners ;) So on, Windows, it is best to use FFI (but I don't think you can have a blocking mode with this).
HTH,
Dave
So on, Windows, it is best to use FFI (but I don't think you can have a blocking mode with this).
You can check if a process has exited using FFI on Windows.
First use the kernel32 api CreateProcess to launch the process and retrieve its handle.
The repeatedly call GetExitCodeProcess to find out whether the process has exited.
Short sample attached.
fileIn and evaluate (WinProcess runNotepadAndInformWhenDone) to try it out.
beginners@lists.squeakfoundation.org