Using squeak with a script?

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

Using squeak with a script?

Jacques Harmand
Hi list,
I try to use squeak to execute the following basic Smalltalk script (in a file "hello.st")
"Transcript show: 'Hello world'; cr."
from the command line with Squeak.  This works as expected with both GNU Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to wait forever.  If I add
"Smalltalk snapshot: false andQuit: true."
after the above line, the execution of the script terminates, but without printing anything.
I use the Squeak 5.0-201608171728 VM and the Squeak5.1-16548 image.
Any hints?
Thank you.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

Göran Krampe
On 21/02/17 20:51, Jacques Harmand wrote:

> Hi list,
> I try to use squeak to execute the following basic Smalltalk script (in
> a file "hello.st <http://hello.st>")
> "Transcript show: 'Hello world'; cr."
> from the command line with Squeak.  This works as expected with both GNU
> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
> wait forever.  If I add
> "Smalltalk snapshot: false andQuit: true."
> after the above line, the execution of the script terminates, but
> without printing anything.

I haven't looked closely at latest Squeak (perhaps Pharo has coupled
Transcript to stdout for headless mode?), but Transcript is not the same
thing as stdout - so you wouldn't see anything on stdout.

regards, Göran
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

Hannes Hirzel
Maybe

      ExternalCommandShell

     http://wiki.squeak.org/squeak/6023

this is of some help?

--Hannes

On 2/22/17, Göran Krampe <[hidden email]> wrote:

> On 21/02/17 20:51, Jacques Harmand wrote:
>> Hi list,
>> I try to use squeak to execute the following basic Smalltalk script (in
>> a file "hello.st <http://hello.st>")
>> "Transcript show: 'Hello world'; cr."
>> from the command line with Squeak.  This works as expected with both GNU
>> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
>> wait forever.  If I add
>> "Smalltalk snapshot: false andQuit: true."
>> after the above line, the execution of the script terminates, but
>> without printing anything.
>
> I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> Transcript to stdout for headless mode?), but Transcript is not the same
> thing as stdout - so you wouldn't see anything on stdout.
>
> regards, Göran
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

Jacques Harmand
Thanks for your answers.
Alas ExternalCommandShell does not seem to work, the VM seems to wait forever.
I also tried various other ways:
"OSProcess thisOSProcess stdOut nextPutAll: 'Hello world'."
"FileStream stdout nextPutAll: 'Hello world'."
"StandardFileStream stdout nextPutAll: 'Hello world'."
"TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'."
... but so far none of them seems to work.
I also tried "-headless" and "-vm-display-null", but again this does not seem to help.
Any pointer would be appreciated!

2017-02-22 15:49 GMT+01:00 H. Hirzel <[hidden email]>:
Maybe

      ExternalCommandShell

     http://wiki.squeak.org/squeak/6023

this is of some help?

--Hannes

On 2/22/17, Göran Krampe <[hidden email]> wrote:
> On 21/02/17 20:51, Jacques Harmand wrote:
>> Hi list,
>> I try to use squeak to execute the following basic Smalltalk script (in
>> a file "hello.st <http://hello.st>")
>> "Transcript show: 'Hello world'; cr."
>> from the command line with Squeak.  This works as expected with both GNU
>> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
>> wait forever.  If I add
>> "Smalltalk snapshot: false andQuit: true."
>> after the above line, the execution of the script terminates, but
>> without printing anything.
>
> I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> Transcript to stdout for headless mode?), but Transcript is not the same
> thing as stdout - so you wouldn't see anything on stdout.
>
> regards, Göran
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

David T. Lewis
Hi Jacques,

Output to the standard output stream may be buffered, and that may be part
of the problem. Try doing this and see if you get the expected output:

  StandardFileStream stdout nextPutAll: 'Hello world'; cr; flush.


On Wed, Feb 22, 2017 at 05:09:21PM +0100, Jacques Harmand wrote:
> Thanks for your answers.
> Alas ExternalCommandShell does not seem to work, the VM seems to wait
> forever.

Be sure that you are running Squeak in the foreground with no '&' at the
end of your command. If you start it in background with a '&' then the
stdin, stdout, and stderr streams will be disconnected from your console,
and both the image and the VM will appear to be stuck as the ExternalCommandShell
tries to read from the disconnected input stream.

I just tried ExternalCommandShell with the latest Squeak, and I see
that it probably needs a few more #flush to get the prompt to display
properly. I'll have to look into that :-)

Dave


> I also tried various other ways:
> "OSProcess thisOSProcess stdOut nextPutAll: 'Hello world'."
> "FileStream stdout nextPutAll: 'Hello world'."
> "StandardFileStream stdout nextPutAll: 'Hello world'."
> "TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'."
> ... but so far none of them seems to work.
> I also tried "-headless" and "-vm-display-null", but again this does not
> seem to help.
> Any pointer would be appreciated!
>
> 2017-02-22 15:49 GMT+01:00 H. Hirzel <[hidden email]>:
>
> > Maybe
> >
> >       ExternalCommandShell
> >
> >      http://wiki.squeak.org/squeak/6023
> >
> > this is of some help?
> >
> > --Hannes
> >
> > On 2/22/17, G??ran Krampe <[hidden email]> wrote:
> > > On 21/02/17 20:51, Jacques Harmand wrote:
> > >> Hi list,
> > >> I try to use squeak to execute the following basic Smalltalk script (in
> > >> a file "hello.st <http://hello.st>")
> > >> "Transcript show: 'Hello world'; cr."
> > >> from the command line with Squeak.  This works as expected with both GNU
> > >> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
> > >> wait forever.  If I add
> > >> "Smalltalk snapshot: false andQuit: true."
> > >> after the above line, the execution of the script terminates, but
> > >> without printing anything.
> > >
> > > I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> > > Transcript to stdout for headless mode?), but Transcript is not the same
> > > thing as stdout - so you wouldn't see anything on stdout.
> > >
> > > regards, G??ran
> > > _______________________________________________
> > > Beginners mailing list
> > > [hidden email]
> > > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> > >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> >

> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

Jacques Harmand
Thank you also for your answer!
Alas it doesn't work: the VM just waits forever (at least it does not execute the "Smalltalk snapshot: false andQuit: true." on the next line), and nothing is printed at all...
And yes, I run Squeak in the foreground without a '&' at the end of the command line, with:
/path/to/squeak <options> /path/to/Squeak.image $(readlink -f "$1")
where <options> are "-headless" or "-vm-display-null -vm-sound-null".

If that's important, the Squeak 5.0-201608171728 VM I use is cogspur64linux, compiled by myself, because the standard VM that can be downloaded on squeak.org aborts with:
"pthread_setschedparam failed: Operation not permitted Read e.g. https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/tag/r3732#linux"
and I cannot do what is explained on that page because I'm not the admin of the computer.

2017-02-23 1:47 GMT+01:00 David T. Lewis <[hidden email]>:
Hi Jacques,

Output to the standard output stream may be buffered, and that may be part
of the problem. Try doing this and see if you get the expected output:

  StandardFileStream stdout nextPutAll: 'Hello world'; cr; flush.


On Wed, Feb 22, 2017 at 05:09:21PM +0100, Jacques Harmand wrote:
> Thanks for your answers.
> Alas ExternalCommandShell does not seem to work, the VM seems to wait
> forever.

Be sure that you are running Squeak in the foreground with no '&' at the
end of your command. If you start it in background with a '&' then the
stdin, stdout, and stderr streams will be disconnected from your console,
and both the image and the VM will appear to be stuck as the ExternalCommandShell
tries to read from the disconnected input stream.

I just tried ExternalCommandShell with the latest Squeak, and I see
that it probably needs a few more #flush to get the prompt to display
properly. I'll have to look into that :-)

Dave


> I also tried various other ways:
> "OSProcess thisOSProcess stdOut nextPutAll: 'Hello world'."
> "FileStream stdout nextPutAll: 'Hello world'."
> "StandardFileStream stdout nextPutAll: 'Hello world'."
> "TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'."
> ... but so far none of them seems to work.
> I also tried "-headless" and "-vm-display-null", but again this does not
> seem to help.
> Any pointer would be appreciated!
>
> 2017-02-22 15:49 GMT+01:00 H. Hirzel <[hidden email]>:
>
> > Maybe
> >
> >       ExternalCommandShell
> >
> >      http://wiki.squeak.org/squeak/6023
> >
> > this is of some help?
> >
> > --Hannes
> >
> > On 2/22/17, G??ran Krampe <[hidden email]> wrote:
> > > On 21/02/17 20:51, Jacques Harmand wrote:
> > >> Hi list,
> > >> I try to use squeak to execute the following basic Smalltalk script (in
> > >> a file "hello.st <http://hello.st>")
> > >> "Transcript show: 'Hello world'; cr."
> > >> from the command line with Squeak.  This works as expected with both GNU
> > >> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
> > >> wait forever.  If I add
> > >> "Smalltalk snapshot: false andQuit: true."
> > >> after the above line, the execution of the script terminates, but
> > >> without printing anything.
> > >
> > > I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> > > Transcript to stdout for headless mode?), but Transcript is not the same
> > > thing as stdout - so you wouldn't see anything on stdout.
> > >
> > > regards, G??ran
> > > _______________________________________________
> > > Beginners mailing list
> > > [hidden email]
> > > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> > >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> >

> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Using squeak with a script?

Jacques Harmand
I just installed the standard VM from squeak.org on another computer on which I have admin privileges, and I get the exact same results (or rather absence of results), so it's not related to the fact that I used a non-completely-standard VM:
"OSProcess thisOSProcess stdOut nextPutAll: 'Hello world'. Smalltalk snapshot: false andQuit: true." waits forever
"Transcript show: 'Hello world'; cr. Smalltalk snapshot: false andQuit: true." terminates but does not print anything
"TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'. Smalltalk snapshot: false andQuit: true." terminates but does not print anything
"StandardFileStream stdout nextPutAll: 'Hello world'. Smalltalk snapshot: false andQuit: true." waits forever
"ExternalCommandShell start. Transcript show: 'Hello world'. ExternalCommandShell stop. Smalltalk snapshot: false andQuit: true." waits forever
"StandardFileStream stdout nextPutAll: 'Hello world'; cr; flush. Smalltalk snapshot: false andQuit: true." waits forever
"TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'. Transcript endEntry. Smalltalk snapshot: false andQuit: true." terminates but does not print anything


2017-02-23 8:57 GMT+01:00 Jacques Harmand <[hidden email]>:
Thank you also for your answer!
Alas it doesn't work: the VM just waits forever (at least it does not execute the "Smalltalk snapshot: false andQuit: true." on the next line), and nothing is printed at all...
And yes, I run Squeak in the foreground without a '&' at the end of the command line, with:
/path/to/squeak <options> /path/to/Squeak.image $(readlink -f "$1")
where <options> are "-headless" or "-vm-display-null -vm-sound-null".

If that's important, the Squeak 5.0-201608171728 VM I use is cogspur64linux, compiled by myself, because the standard VM that can be downloaded on squeak.org aborts with:
"pthread_setschedparam failed: Operation not permitted Read e.g. https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/tag/r3732#linux"
and I cannot do what is explained on that page because I'm not the admin of the computer.

2017-02-23 1:47 GMT+01:00 David T. Lewis <[hidden email]>:
Hi Jacques,

Output to the standard output stream may be buffered, and that may be part
of the problem. Try doing this and see if you get the expected output:

  StandardFileStream stdout nextPutAll: 'Hello world'; cr; flush.


On Wed, Feb 22, 2017 at 05:09:21PM +0100, Jacques Harmand wrote:
> Thanks for your answers.
> Alas ExternalCommandShell does not seem to work, the VM seems to wait
> forever.

Be sure that you are running Squeak in the foreground with no '&' at the
end of your command. If you start it in background with a '&' then the
stdin, stdout, and stderr streams will be disconnected from your console,
and both the image and the VM will appear to be stuck as the ExternalCommandShell
tries to read from the disconnected input stream.

I just tried ExternalCommandShell with the latest Squeak, and I see
that it probably needs a few more #flush to get the prompt to display
properly. I'll have to look into that :-)

Dave


> I also tried various other ways:
> "OSProcess thisOSProcess stdOut nextPutAll: 'Hello world'."
> "FileStream stdout nextPutAll: 'Hello world'."
> "StandardFileStream stdout nextPutAll: 'Hello world'."
> "TranscriptStream redirectToStdOut: true. Transcript show: 'Hello world'."
> ... but so far none of them seems to work.
> I also tried "-headless" and "-vm-display-null", but again this does not
> seem to help.
> Any pointer would be appreciated!
>
> 2017-02-22 15:49 GMT+01:00 H. Hirzel <[hidden email]>:
>
> > Maybe
> >
> >       ExternalCommandShell
> >
> >      http://wiki.squeak.org/squeak/6023
> >
> > this is of some help?
> >
> > --Hannes
> >
> > On 2/22/17, G??ran Krampe <[hidden email]> wrote:
> > > On 21/02/17 20:51, Jacques Harmand wrote:
> > >> Hi list,
> > >> I try to use squeak to execute the following basic Smalltalk script (in
> > >> a file "hello.st <http://hello.st>")
> > >> "Transcript show: 'Hello world'; cr."
> > >> from the command line with Squeak.  This works as expected with both GNU
> > >> Smalltalk and Pharo, but with Squeak nothing happens: Squeak seems to
> > >> wait forever.  If I add
> > >> "Smalltalk snapshot: false andQuit: true."
> > >> after the above line, the execution of the script terminates, but
> > >> without printing anything.
> > >
> > > I haven't looked closely at latest Squeak (perhaps Pharo has coupled
> > > Transcript to stdout for headless mode?), but Transcript is not the same
> > > thing as stdout - so you wouldn't see anything on stdout.
> > >
> > > regards, G??ran
> > > _______________________________________________
> > > Beginners mailing list
> > > [hidden email]
> > > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> > >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> >

> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners