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? If so, pointers to documentation on this would be much appreciated. --- Mark Volkmann _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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? Yes. > If so, pointers to documentation on this would be much appreciated. http://wiki.squeak.org/squeak/708 - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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? Bert> Yes. >> If so, pointers to documentation on this would be much appreciated. Bert> http://wiki.squeak.org/squeak/708 That's for Squeak creating child processes. I *think* the question is more along the lines of: http://wiki.squeak.org/squeak/425 as in, "how can I run Squeak from a command line, and get access to the command-line arguments?" The longer answer is that we generally *don't* do that, so there's not a lot of discussion or support for it, but there it is. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Am 26.09.2008 um 05:48 schrieb Randal L. Schwartz: >>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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? > > Bert> Yes. > >>> If so, pointers to documentation on this would be much appreciated. > > > Bert> http://wiki.squeak.org/squeak/708 > > That's for Squeak creating child processes. OSProcess has primitives to open stdin/stdout/stderr as streams. It does much more too, but that was what the OP wanted to know. - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Randal L. Schwartz
>>>>> "Randal" == Randal L Schwartz <[hidden email]> writes:
>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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" -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Bert Freudenberg
Probably worth mentioning that GNU Smalltalk targets that kind of application. I don't use it, so I can't tell you how nice it is (except that when I tried it, there wasn't a working gui, so I went away).
On 9/26/08, Randal L. Schwartz <[hidden email]> wrote:
>>>>> "Bert" == Bert Freudenberg <[hidden email]> writes: _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Randal L. Schwartz
On Sep 26, 2008, at 8:03 AM, Randal L. Schwartz wrote:
"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? --- Mark Volkmann _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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 <[hidden email]> writes: >> >>>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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). - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
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 <[hidden email]> writes: >>> >>>>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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. --- Mark Volkmann _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
I'm a beginner myself, but I would think it would be better to have squeak running all the time and let is handle the cron timing, and connecting to the database (kind of like a service of it's own). I would think this would be easier to debug and maintain as well as being more within the paradigm of squeak.
Better still would be if we got SqueakOS to the point where Squeak noobs like myself could use it in place of Windows :) On Fri, Sep 26, 2008 at 10:33 AM, Mark Volkmann <[hidden email]> wrote:
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Mark Volkmann
On Friday 26 Sep 2008 5:42:48 pm Mark Volkmann wrote:
> 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? If so, > pointers to documentation on this would be much appreciated. Others have answered how you can do this, but please do take a step back and explain what you are trying do to get a more appropriate response. Unix systems use a pipeline architecture ( a | b | c ) to do complex processing on data streams using simpler filter apps. Squeak is not a filter. It is a virtual machine that runs a whole environment of communicating objects. If the stream processing needs are complex, then run squeak as a headless daemon listening on a socket and use filters like netcat to handle traffic between file streams and socket streams. Or you could use named pipes and do traditional file i/o in Smalltalk. But be aware that you are mixing two different architectures here. I suppose you can make Squeak do whatever you want. It is all a simple matter of programming (SMOP) :-). HTH .. Subbu _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Mark Volkmann
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 <[hidden email]> writes: >>>> >>>>>>>>> "Bert" == Bert Freudenberg <[hidden email]> 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 [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Mark Volkmann
Well, doing all the timing management in one place may aid synchronisation.
In any case, I second Subbu's sentiments.
On 9/26/08, Ryan Zerby <[hidden email]> wrote:
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |