Am 26.09.2008 um 07:33 schrieb Mark Volkmann:

On Sep 26, 2008, at 9:29 AM, Bert Freudenberg wrote:

Am 26.09.2008 um 06:49 schrieb Mark Volkmann:

On Sep 26, 2008, at 8:03 AM, Randal L. Schwartz wrote:

"Randal" == Randal L Schwartz <[EMAIL PROTECTED]> writes:

"Bert" == Bert Freudenberg <[EMAIL PROTECTED]> writes:
Bert> Am 26.09.2008 um 05:12 schrieb Mark Volkmann:

Is it possible to run a Squeak program from a terminal window and have
access to the stdin and stdout streams from the Smalltalk code?

And the longer still answer (now that I've noticed "access to stdin and
stdout") is to use an image with OSProcess loaded, and then you can
get access as follows:

me := ThisOSProcess thisOSProcess.
stdin := me stdIn. "acts like a Stream"
stdout := me stdOut.
stderr := me stdErr.
stderr print: Time now; cr. "put the time of day on my stderr output"


Thanks for the example code! Now I think all I need is to find out how to launch the code from a terminal window. At http://wiki.squeak.org/squeak/1914 I found this.

"To initiate external shell processing, evaluate ''ExternalCommandShell stop'', save the image, and restart with ''squeak -headless myImage''."

It's not clear to me what will be run when that last command is executed from a terminal window. Where would I put code like your example code above and how does the squeak command know to execute it?

Perhaps you should let us know what you want to achieve in broader terms first. Using Squeak in a headless way to do unix-style stream processing is very unusual. It can be done but it is not something I would recommend to a beginner.

This is in contrast to many other languages which are most easily learned by creating simple programs writing to stdin/stdout. The power of Squeak is in the system (the development tools and frameworks), not so much the language (which is powerful, too, but not really what sets Squeak apart).


I'm really trying to learn about all aspects of Squeak, but at the moment I have a task where I need to query a relational database and output an XML representation of a subset of the data. This needs to be invoked from a cron job, so if I can run my Smalltalk code from a terminal window then I'll be set. I know I could do this using many other languages such as Java or Ruby. However, since I'm trying to learn Smalltalk and Squeak at the moment, I thought I'd use those as part of the learning process.


You're signing up for pain then ;)

Squeak was not made for this kind of task. It is possible to do of course, but more complicated than we would like. You might run into many problems that could easily make you miss what's so great about Squeak.

OTOH one thing that's great about Squeak is its friendly community, so I'm sure someone will help you along :)

- Bert -


_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to