Console smalltalk program.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Console smalltalk program.

Adrian Norberto Marino
Hello,
        I need write a console program with smalltalk squeak.
        Exist any tool for this task in squeak?

Thanks.
--
Adrian Norberto Marino <[hidden email]>
J2EE Developer.
Gentoo/Debian GNU/Linux User 380562.

...With free software you have freedom!...


Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Bert Freudenberg
On 19.03.2010, at 00:53, Adrian Norberto Marino wrote:
>
> Hello,
> I need write a console program with smalltalk squeak.
> Exist any tool for this task in squeak?

Yes (*)

- Bert -

(*) http://catb.org/~esr/faqs/smart-questions.html#intro

Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Michael van der Gulik-2
In reply to this post by Adrian Norberto Marino
On Fri, Mar 19, 2010 at 12:53 PM, Adrian Norberto Marino
<[hidden email]> wrote:
> Hello,
>        I need write a console program with smalltalk squeak.
>        Exist any tool for this task in squeak?

What I think you want is a package called OSProcess. This is available
from within Squeak: open the Package Universe browser and you'll find
it under the "System" category. Then see OSProcess class>>helloWorld
and other examples.

Also check out the CommandShell package.

This is a telnet server in Squeak called "REPLServer" (under the
"Network" category) which implements a Smalltalk-like command line
with history, editing and a few other features. You could re-use much
of the code there if you want. I think that every operating system has
a telnet client, so you get a free command line for any platform.

I haven't seen any ncurses-like functionality in Squeak before. In my
opinion, that type of environment has been long obsolete and you
should just use a modern GUI.

Gulik.

--
http://gulik.pbwiki.com/

Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Michael van der Gulik-2
In reply to this post by Bert Freudenberg
On Fri, Mar 19, 2010 at 1:01 PM, Bert Freudenberg <[hidden email]> wrote:

> On 19.03.2010, at 00:53, Adrian Norberto Marino wrote:
>>
>> Hello,
>>       I need write a console program with smalltalk squeak.
>>       Exist any tool for this task in squeak?
>
> Yes (*)
>
> - Bert -
>
> (*) http://catb.org/~esr/faqs/smart-questions.html#intro

tl;dr :-)

Gulik.


--
http://gulik.pbwiki.com/

Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

David T. Lewis
In reply to this post by Michael van der Gulik-2
On Fri, Mar 19, 2010 at 01:27:45PM +1300, Michael van der Gulik wrote:

> On Fri, Mar 19, 2010 at 12:53 PM, Adrian Norberto Marino
> <[hidden email]> wrote:
> > Hello,
> > ? ? ? ?I need write a console program with smalltalk squeak.
> > ? ? ? ?Exist any tool for this task in squeak?
>
> What I think you want is a package called OSProcess. This is available
> from within Squeak: open the Package Universe browser and you'll find
> it under the "System" category. Then see OSProcess class>>helloWorld
> and other examples.
>
> Also check out the CommandShell package.

FYI, you can load the latest versions of OSProcess/CommandShell from
SqueakSource. It's generally best to use the latest version, as I
don't keep the universes postings up to date as much as I should do.

To run Squeak as a /bin/sh replacement, see class ExternalCommandShell
in the CommandShell package, which is described here:
  http://wiki.squeak.org/squeak/6023

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Adrian Norberto Marino
Thanks for all!

First of all apologies for my low level of English.
I Found a way to execute smalltak code from a squeak image
from unix bash that was what he needed, Of the next form:

1. evaluate "ExternCommandShell start" from squeak image.
2. Close squeak image
3. run from unix shell(bash): squeak -headless myImage
4. This open a sqsh interpreter.
4. Now run by example: Array with: 'Helo'

it possible execute a squeak smalltalk expression of the next way?

bash$  squeak -headless myImage  Array with: 'Helo'

my idea is execute a smalltalk espression directly desde bash.

Thanks.

El jue, 18-03-2010 a las 21:53 -0400, David T. Lewis escribió:

> On Fri, Mar 19, 2010 at 01:27:45PM +1300, Michael van der Gulik wrote:
> > On Fri, Mar 19, 2010 at 12:53 PM, Adrian Norberto Marino
> > <[hidden email]> wrote:
> > > Hello,
> > > ? ? ? ?I need write a console program with smalltalk squeak.
> > > ? ? ? ?Exist any tool for this task in squeak?
> >
> > What I think you want is a package called OSProcess. This is available
> > from within Squeak: open the Package Universe browser and you'll find
> > it under the "System" category. Then see OSProcess class>>helloWorld
> > and other examples.
> >
> > Also check out the CommandShell package.
>
> FYI, you can load the latest versions of OSProcess/CommandShell from
> SqueakSource. It's generally best to use the latest version, as I
> don't keep the universes postings up to date as much as I should do.
>
> To run Squeak as a /bin/sh replacement, see class ExternalCommandShell
> in the CommandShell package, which is described here:
>   http://wiki.squeak.org/squeak/6023
>
> Dave
>
>
--
Adrian Norberto Marino <[hidden email]>
J2EE Developer.
Gentoo/Debian GNU/Linux User 380562.

...With free software you have freedom!...


Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Chris Muller-3
In reply to this post by David T. Lewis
I think CommandShell is neat, and have it loaded in my dev image.  It
provides nice interface to the Linux environment from within the
image.

Dave, would you mind if, in some future release of CommandShell, the
category for the test cases could be renamed so as to not cause a
dirty package in the trunk image?

Cheers,
  Chris

On Thu, Mar 18, 2010 at 8:53 PM, David T. Lewis <[hidden email]> wrote:

> On Fri, Mar 19, 2010 at 01:27:45PM +1300, Michael van der Gulik wrote:
>> On Fri, Mar 19, 2010 at 12:53 PM, Adrian Norberto Marino
>> <[hidden email]> wrote:
>> > Hello,
>> > ? ? ? ?I need write a console program with smalltalk squeak.
>> > ? ? ? ?Exist any tool for this task in squeak?
>>
>> What I think you want is a package called OSProcess. This is available
>> from within Squeak: open the Package Universe browser and you'll find
>> it under the "System" category. Then see OSProcess class>>helloWorld
>> and other examples.
>>
>> Also check out the CommandShell package.
>
> FYI, you can load the latest versions of OSProcess/CommandShell from
> SqueakSource. It's generally best to use the latest version, as I
> don't keep the universes postings up to date as much as I should do.
>
> To run Squeak as a /bin/sh replacement, see class ExternalCommandShell
> in the CommandShell package, which is described here:
>  http://wiki.squeak.org/squeak/6023
>
> Dave
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

Michael van der Gulik-2
In reply to this post by Adrian Norberto Marino
On Fri, Mar 19, 2010 at 3:15 PM, Adrian Norberto Marino
<[hidden email]> wrote:

> Thanks for all!
>
> First of all apologies for my low level of English.
> I Found a way to execute smalltak code from a squeak image
> from unix bash that was what he needed, Of the next form:
>
> 1. evaluate "ExternCommandShell start" from squeak image.
> 2. Close squeak image
> 3. run from unix shell(bash): squeak -headless myImage
> 4. This open a sqsh interpreter.
> 4. Now run by example: Array with: 'Helo'
>
> it possible execute a squeak smalltalk expression of the next way?
>
> bash$  squeak -headless myImage  Array with: 'Helo'
>
> my idea is execute a smalltalk espression directly desde bash.

This has been discussed before. If you search this mailing list,
you'll find a discussion.

"OSProcess arguments" will return the arguments passed on the command line.

Then you'll also want to know about:

SystemDictionary>>addToStartUpList:   " lets you run code when the
image starts. "
(Smalltalk is the only instance of SystemDictionary)

SmalltalkImage>>snapshot:andQuit:embedded: " To shut the image down
and return to bash. "

"Compiler evaluate:" will compile and run code.

Or... I think that GNU Smalltalk supports this kind of thing much better.

Gulik.

--
http://gulik.pbwiki.com/

Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

David T. Lewis
In reply to this post by Chris Muller-3
On Thu, Mar 18, 2010 at 09:24:22PM -0500, Chris Muller wrote:
> I think CommandShell is neat, and have it loaded in my dev image.  It
> provides nice interface to the Linux environment from within the
> image.
>
> Dave, would you mind if, in some future release of CommandShell, the
> category for the test cases could be renamed so as to not cause a
> dirty package in the trunk image?

Chris,

Absolutely yes, and I need to fix OSProcess packaging similarly. And
I should also repackage them so the MVC and Morphic portions are
separated, so the Pharo folks don't get errors trying to load
all the MVC stuff.

On my to-do list :-/

Thanks for the reminder,

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Console smalltalk program.

David T. Lewis
In reply to this post by Adrian Norberto Marino
On Thu, Mar 18, 2010 at 11:15:10PM -0300, Adrian Norberto Marino wrote:

> Thanks for all!
>
> First of all apologies for my low level of English.
> I Found a way to execute smalltak code from a squeak image
> from unix bash that was what he needed, Of the next form:
>
> 1. evaluate "ExternCommandShell start" from squeak image.
> 2. Close squeak image
> 3. run from unix shell(bash): squeak -headless myImage
> 4. This open a sqsh interpreter.
> 4. Now run by example: Array with: 'Helo'
>
> it possible execute a squeak smalltalk expression of the next way?
>
> bash$  squeak -headless myImage  Array with: 'Helo'
>
> my idea is execute a smalltalk espression directly desde bash.

Instead of putting the Smalltalk expression on the command line,
you can send it to stdin like this:

  bash$ echo "Array with: 'Helo' ! ; exit" | squeak -headless myImage

The $! after the Smalltalk expression means interpret the expression
as a Smalltalk doIt instead of as Unix command.

ExternalCommandShell will evaluate "Array with: 'Helo' !" as a
Smalltalk expression and print the result on console. Then it
evaluates "exit" as a command, and the Squeak image will exit.

Dave

p.s. Your English is good enough!