[newbie] Executing software in squeak using a command line.

Ned Konz ned at squeakland.org
Thu Feb 24 16:09:17 UTC 2005


On Thursday 24 February 2005 7:23 am, sergio.rivero wrote:
> Hello!
>
> I'm trying so execute in a Grid a small piece of code that
> I've wrote in Squeak.
>
> There is some way to execute an application in Squeak
> using a command line?  (in Linux).
>
> Could be something like...
>
> squeak -someOption myImage.image MyClass new myMethod.
>
> I don't want to see the user interface...
> The method myMethod will generate some files to analyse.

I think this is explained in the man page. Look at the section entitled 
SCRIPTS. Just as a note, I have found that with some versions of Squeak I 
needed to provide an absolute URL for files as well 
(file:///full/path/to/script).

However, here's an example. I have a script that I run across all my images 
(from a shell script) to summarize their contents and output the summary to 
text files.

The script is run like this:

squeak -vm display=null -vm sound=null -mmap 512M  squeak.image 
file:///home/ned/summarize.st

where summarize.st looks like something like this (I belive that I had to put 
the '!' at the end to get it to work right):

---
| fname |
Preferences disable: #warnIfNoSourcesFile.
Preferences disable: #warnIfNoChangesFile.
Preferences disable: #showDeprecationWarnings.

fname := SmalltalkImage current getSystemAttribute: 3.
"... do some stuff..."
SmalltalkImage current snapshot: false andQuit: true.
!
---

Both the Squeak script and the shell script that runs it are attached.

-- 
Ned Konz
http://bike-nomad.com/squeak/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: summarizeAllImages
Type: application/x-shellscript
Size: 836 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20050224/8fcd735a/summarizeAllImages.bin
-------------- next part --------------
| f fname version sstring newInformant |

Preferences disable: #warnIfNoSourcesFile.
Preferences disable: #warnIfNoChangesFile.
Preferences disable: #showDeprecationWarnings.

fname := SmalltalkImage current getSystemAttribute: 3.
f := fname
	ifNil: [ CrLfFileStream fileNamed: (SmalltalkImage current imageName, '.contents') ]
	ifNotNil: [ (CrLfFileStream fileNamed: fname) setToEnd;
		nextPutAll: '-----------------'; cr; yourself  ].

f nextPutAll: (SmalltalkImage current getSystemAttribute: 1); cr.

version := (Smalltalk at: #SystemVersion)
	ifNotNil: [ (Smalltalk at: #SystemVersion) current printString ]
	ifNil: [ Smalltalk version ].
f nextPutAll: version; cr.

Object basicRemoveSelector: #inform:.
Object basicRemoveSelector: #confirm:.

[
	Smalltalk forgetDoIts.

	sstring := String new: 20000.

	ChangeSet allInstances do: [ :ea | | hash sstream |
		sstream := ReadWriteStream on: sstring.
		ea fileOutOn: sstream.
		sstream reset.
		hash := sstream atEnd ifTrue: [ 0 ] ifFalse: [ SecureHashAlgorithm new hashStream: sstream ].
		f nextPutAll: '>> ';
			nextPutAll: hash hex; space; 
			nextPutAll: ea summaryString squeakToIso.
	].
]
on: Error do: [ :ex | | ctxt |
f cr; nextPutAll: ex description; cr.
(ex isKindOf: MessageNotUnderstood) ifTrue: [ f nextPutAll: 'args='; print: ex message arguments; cr ].
f nextPutAll: ex signalerContext shortStack; cr.
ex return: nil ].

SmalltalkImage current snapshot: false andQuit: true.

"not caught:
Object>>inform:
Object>>confirm:
"

!


More information about the Squeak-dev mailing list