[squeak-dev] How to use OSProcess with stdin and stdout

Martin Kuball martinkuball at web.de
Tue May 26 19:26:06 UTC 2020


Hi Sean,

your solution with temp files is definitely simpler and more maintainable. But
for sheer ambition I wanted to do it without. But at the moment I have not
enough ambition to do it with FFI. Getting the data structures right is not
that easy. I remember having a hard time writing a connector for the xvid
library more than 10 years ago. But I had a lot more spare time back than.

Martin


Am Dienstag, 26. Mai 2020, 15:44:53 CEST schrieb Sean P. DeNigris:
> Sorry, I just saw this thread. For the future, I did a small wrapper like
> this that might help [1]. It looks like I didn't convert the repo to Tonel
> yet and IIRC there are few dependencies other than OSP, so it may load in
> Squeak (or could be used for inspiration). I would also be happy to accept
> PRs to make it so. I probably will convert to Tonel at some point - although
> it looks like Tonel support in Squeak may be imminent, so hopefully no
> problem there :)
>
>
> Martin Kuball wrote
>
> > Mybe it is possible to reuse more of your high-level code.
>
> This is what I ended up with [2]:
> 	| p result |
>
> 	p := PipeableOSProcess waitForCommand: commandString.
> 	p succeeded ifFalse: [ ^ self error: 'tesseract failed with: ', p
> errorUpToEnd ].
> 	result := self tempFile readStreamDo: [ :str | str contents ].
> 	self tempFile delete.
> 	^ result.
>
> If I had to do it again, I'd probably try via FFI. I've had a longstanding
> belief that wrapping command line stuff is an easy way to "get it to work"
> and then I can later "get it right" with FFI, but after doing a lot of this
> sort of thing, there are so many quirks that I think it might usually be
> easier to just start with FFI (although maybe the grass is always
> greener...).
>
> [1]. https://github.com/seandenigris/Tesseract-St
> [2].
> https://github.com/seandenigris/Tesseract-St/blob/master/src/Tesseract.packa
> ge/Tesseract.class/instance/evaluate..st
>
>
>
> -----
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Squeak-Dev-f45488.html






More information about the Squeak-dev mailing list