[squeak-dev] running headless on Mac OS X

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

[squeak-dev] running headless on Mac OS X

Mark Volkmann
I need to run Squeak in headless mode on Mac OS X. As far as I know, this is the way to do it.

1) Open a Terminal window.

2) Create a symbolic link by entering
    ln -s "$SQUEAK_VM_DIR/Squeak{version}.app/Contents/MacOS/Squeak VM Opt" squeak

3) Create a text file with a ".st" file extension and add a sequence of Smalltalk statements in it.

4) Enter the following:
    squeak -headless $SQUEAK_IMAGE {filename}.st

When I do this, I don't get any errors, but it just hangs. Here's what I have in the .st file I'm running ... pretty simple.

fs := FileStream newFileNamed: 'cmdline.txt'.
fs nextPutAll: 'line 1'; cr.
fs nextPutAll: 'line 2'.
fs.close

Any idea why it doesn't exit? Maybe I need to do something more at the end of the .st file.

Maybe it's related to this. If I run "squeak $SQUEAK_IMAGE", it tries to start the Squeak UI, but I get an Information dialog that says "Squeak cannot locate the sources file named /Users.Mark/SqueakV39.sources". I copied the .sources file to my home directory and ran it again. This time the UI came up, but it doesn't respond to mouse clicks.

---
Mark Volkmann






Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] running headless on Mac OS X

John M McIntosh-2
Well actually I think you can alter the info.plist and set  
LSBackgroundOnly  to YES
the alter the SqueakImageName  to point to the image you want to run
the invoke open Squeak.app  and it should open as background  
application, no icon in dock
and run the image file that is found via the SqueakImageName

However it appears you are doing scripting? via supplying a *.st file  
at startup time.
Try to get it to work with a UI first, then try the headless option or  
LSBackgroundOnly

On Oct 5, 2008, at 5:06 PM, Mark Volkmann wrote:

> I need to run Squeak in headless mode on Mac OS X. As far as I know,  
> this is the way to do it.
>
> 1) Open a Terminal window.
>
> 2) Create a symbolic link by entering
>     ln -s "$SQUEAK_VM_DIR/Squeak{version}.app/Contents/MacOS/Squeak  
> VM Opt" squeak
>
> 3) Create a text file with a ".st" file extension and add a sequence  
> of Smalltalk statements in it.
>
> 4) Enter the following:
>     squeak -headless $SQUEAK_IMAGE {filename}.st
>
> When I do this, I don't get any errors, but it just hangs. Here's  
> what I have in the .st file I'm running ... pretty simple.
>
> fs := FileStream newFileNamed: 'cmdline.txt'.
> fs nextPutAll: 'line 1'; cr.
> fs nextPutAll: 'line 2'.
> fs.close
>
> Any idea why it doesn't exit? Maybe I need to do something more at  
> the end of the .st file.
>
> Maybe it's related to this. If I run "squeak $SQUEAK_IMAGE", it  
> tries to start the Squeak UI, but I get an Information dialog that  
> says "Squeak cannot locate the sources file named /Users.Mark/
> SqueakV39.sources". I copied the .sources file to my home directory  
> and ran it again. This time the UI came up, but it doesn't respond  
> to mouse clicks.
>
> ---
> Mark Volkmann
>
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] running headless on Mac OS X

Mark Volkmann
On Oct 5, 2008, at 8:13 PM, John M McIntosh wrote:

> Well actually I think you can alter the info.plist and set  
> LSBackgroundOnly  to YES
> the alter the SqueakImageName  to point to the image you want to run
> the invoke open Squeak.app  and it should open as background  
> application, no icon in dock
> and run the image file that is found via the SqueakImageName
>
> However it appears you are doing scripting? via supplying a *.st  
> file at startup time.
> Try to get it to work with a UI first, then try the headless option  
> or LSBackgroundOnly

Thanks for the advice!

The code below that writes two lines to a text file named  
"cmdline.txt" does work when run in the UI, but when I try to run that  
code from a .st file using -headless, it hangs.

Do you think I'd be better off to put the code in an image and  
customize the image so it runs headless? I don't really have a  
preference. I just need a pointer to some documentation on how to do  
it either way. For example, I don't yet know how to configure an image  
to tell it that I want certain code to run when the image starts up.

> On Oct 5, 2008, at 5:06 PM, Mark Volkmann wrote:
>
>> I need to run Squeak in headless mode on Mac OS X. As far as I  
>> know, this is the way to do it.
>>
>> 1) Open a Terminal window.
>>
>> 2) Create a symbolic link by entering
>>    ln -s "$SQUEAK_VM_DIR/Squeak{version}.app/Contents/MacOS/Squeak  
>> VM Opt" squeak
>>
>> 3) Create a text file with a ".st" file extension and add a  
>> sequence of Smalltalk statements in it.
>>
>> 4) Enter the following:
>>    squeak -headless $SQUEAK_IMAGE {filename}.st
>>
>> When I do this, I don't get any errors, but it just hangs. Here's  
>> what I have in the .st file I'm running ... pretty simple.
>>
>> fs := FileStream newFileNamed: 'cmdline.txt'.
>> fs nextPutAll: 'line 1'; cr.
>> fs nextPutAll: 'line 2'.
>> fs.close
>>
>> Any idea why it doesn't exit? Maybe I need to do something more at  
>> the end of the .st file.
>>
>> Maybe it's related to this. If I run "squeak $SQUEAK_IMAGE", it  
>> tries to start the Squeak UI, but I get an Information dialog that  
>> says "Squeak cannot locate the sources file named /Users.Mark/
>> SqueakV39.sources". I copied the .sources file to my home directory  
>> and ran it again. This time the UI came up, but it doesn't respond  
>> to mouse clicks.


---
Mark Volkmann





Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] running headless on Mac OS X

Herbert König
Hello Mark,
MV> it either way. For example, I don't yet know how to configure an image
MV> to tell it that I want certain code to run when the image starts up.

I add these two lines to a .st script I create my autostart images
with:

Smalltalk addToStartUpList: YourApplicationClass
SmalltalkImage current snapshot: true andQuit: true.


YourApplicationClass needs a startUp and I guess a startUp:
on the class side.

As my startUp only reads self startUp: nil maybe one of them is
obsolete.

If a thing works, I tend to forget about the details :-)


--
Cheers,

Herbert                                        


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] running headless on Mac OS X

Mark Volkmann
In reply to this post by John M McIntosh-2
Okay, I think I've got a handle on how StartUpList and ShutDownList in  
SystemDictionary are used.

1) I created a class named MyApplication and gave it a class startUp  
method that creates a text file.
2) I added MyApplication to the SystemDictionary StartUpList and saved  
the image.
When I start the image from the command line using "squeak  
$SQUEAK_IMAGE cmdline.st", it does create the text file. Success!

However, the UI doesn't respond to the mouse when I start it this way  
so I have to kill Squeak from the OS.

When I run it with "squeak -headless $SQUEAK_IMAGE cmdline.st", it  
just hangs and doesn't write the file.

I'm running on Mac OS X using Squeak-Dev 3.10.

Any idea why either of these problems is happening?

On Oct 5, 2008, at 8:13 PM, John M McIntosh wrote:

> Well actually I think you can alter the info.plist and set  
> LSBackgroundOnly  to YES
> the alter the SqueakImageName  to point to the image you want to run
> the invoke open Squeak.app  and it should open as background  
> application, no icon in dock
> and run the image file that is found via the SqueakImageName
>
> However it appears you are doing scripting? via supplying a *.st  
> file at startup time.
> Try to get it to work with a UI first, then try the headless option  
> or LSBackgroundOnly
>
> On Oct 5, 2008, at 5:06 PM, Mark Volkmann wrote:
>
>> I need to run Squeak in headless mode on Mac OS X. As far as I  
>> know, this is the way to do it.
>>
>> 1) Open a Terminal window.
>>
>> 2) Create a symbolic link by entering
>>    ln -s "$SQUEAK_VM_DIR/Squeak{version}.app/Contents/MacOS/Squeak  
>> VM Opt" squeak
>>
>> 3) Create a text file with a ".st" file extension and add a  
>> sequence of Smalltalk statements in it.
>>
>> 4) Enter the following:
>>    squeak -headless $SQUEAK_IMAGE {filename}.st
>>
>> When I do this, I don't get any errors, but it just hangs. Here's  
>> what I have in the .st file I'm running ... pretty simple.
>>
>> fs := FileStream newFileNamed: 'cmdline.txt'.
>> fs nextPutAll: 'line 1'; cr.
>> fs nextPutAll: 'line 2'.
>> fs.close
>>
>> Any idea why it doesn't exit? Maybe I need to do something more at  
>> the end of the .st file.
>>
>> Maybe it's related to this. If I run "squeak $SQUEAK_IMAGE", it  
>> tries to start the Squeak UI, but I get an Information dialog that  
>> says "Squeak cannot locate the sources file named /Users.Mark/
>> SqueakV39.sources". I copied the .sources file to my home directory  
>> and ran it again. This time the UI came up, but it doesn't respond  
>> to mouse clicks.


---
Mark Volkmann