How to access stdout on Mac OS X when using open

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

How to access stdout on Mac OS X when using open

Serge Stinckwich-4
Hi all,
i'm using OSProcess to write something on the mac OS X terminal but when
i execute : OSProcess thisOSProcess stdOut nextPutAll: 'Hello World'.
nothing seems to happen ...

I'm using Squeak 3.8.18beta1U Mac OS X VM, sq3.9-7067dev07.01.1 image
and OSProcess 4.3.3. I launch Squeak from the terminal with the open
command.

When i launch the Squeak binary inside the Squeak application,
the previous expression write the 'Hello World' string on the terminal.


-- Serge Stinckwich
http://doesnotunderstand.free.fr/


Reply | Threaded
Open this post in threaded view
|

Re: How to access stdout on Mac OS X when using open

johnmci
If you did open "Squeak 3.8.18beta1U.app"
that will not work, the open command forks off the process.
If you look in your console.log you should confirm you see the 'Hello  
World'

If you want to launch the binary in a terminal session and keep  
control of the stdin/stdout you must do

./Squeak\ 3.8.18beta1U.app/Contents/MacOS/Squeak\ VM\ Opt

That likely will print these two messages

2007-07-26 03:13:54.252 Squeak VM Opt[7642] CFLog (0): CFMessagePort:  
bootstrap_register(): failed 1103 (0x44f), port = 0x2803,  
name'org.squeak.Squeak.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-26 03:13:54.256 Squeak VM Opt[7642] CFLog (99):  
CFMessagePortCreateLocal(): failed to name Mach port  
(org.squeak.Squeak.ServiceProvider)


And then your test gives.


Hello World


For the curious if you you do

./Squeak\ 3.8.18beta1U.app/Contents/MacOS/Squeak\ VM\ Opt -help

it will print

Usage: ./Squeak 3.8.18beta1U.app/Contents/MacOS/Squeak VM Opt  
[<option>...] [<imageName> [<argument>...]]
        ./Squeak 3.8.18beta1U.app/Contents/MacOS/Squeak VM Opt  
[<option>...] -- [<argument>...]

Common <option>s:
   -help                 print this help message, then exit
   -memory <size>[mk]    use fixed heap size (added to image size)
   -pathenc <enc>        set encoding for pathnames (default: macintosh)
   -headless             run in headless (no window) mode (default:  
false)

Notes:
   <imageName> defaults to `Squeak.image'.
   If `-memory' is not specified then the heap will grow dynamically.
   <argument>s are ignored, but are processed by the Squeak image.
   The first <argument> normally names a Squeak `script' to execute.
   Precede <arguments> by `--' to use default image.

Unix users may feel warm and fuzzy then.....


On Jul 26, 2007, at 1:02 AM, Serge Stinckwich wrote:

> OSProcess thisOSProcess stdOut nextPutAll: 'Hello World'

--
========================================================================
===
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===



Reply | Threaded
Open this post in threaded view
|

RE: How to access stdout on Mac OS X when using open

J J-6
In reply to this post by Serge Stinckwich-4
stdout is normally buffered (no idea how OSProcess is implemented).  Maybe you need to send a #flush command first?

> To: [hidden email]
> From: [hidden email]
> Date: Thu, 26 Jul 2007 10:02:59 +0200
> Subject: How to access stdout on Mac OS X when using open
>
> Hi all,
> i'm using OSProcess to write something on the mac OS X terminal but when
> i execute : OSProcess thisOSProcess stdOut nextPutAll: 'Hello World'.
> nothing seems to happen ...
>
> I'm using Squeak 3.8.18beta1U Mac OS X VM, sq3.9-7067dev07.01.1 image
> and OSProcess 4.3.3. I launch Squeak from the terminal with the open
> command.
>
> When i launch the Squeak binary inside the Squeak application,
> the previous expression write the 'Hello World' string on the terminal.
>
>
> -- Serge Stinckwich
> http://doesnotunderstand.free.fr/
>
>


Don't get caught with egg on your face.    Play Chicktionary!