On Mon, Oct 01, 2012 at 11:09:51AM +0200, Max Leske wrote: > Hi guys > > Is there a way to find out (from outside of the image), if an image has > been saved with Cog? What I would like to do is something like this: > > $ head -20 myImage.image | grep <some expression> > > The use case for this is seaside hosting, where we only have squeak VMs > to run images, so when an image is uploaded that was saved with Cog that > image cause trouble. > Any ideas? > > Cheers, > Max
You should definitely update those older VMs if you can (http://squeakvm.org), but if that is not possible, here is how to check the image format from a shell script. 1) Load package ImageFormat from the VMMaker repository at http://source.squeak.org/VMMaker. 2) Evaluate "ImageFormat createCkStatusProgram" to generate source code ckformat.c. 3) Compile ckformat ($ cc -o ckformat ckformat.c). The ckformat program reads an image file header and prints the image format number on standard output. Non-zero exit status means the format could not be read (e.g. if it was not an image file). You can see how it is used in the /usr/local/bin/squeak script in the latest unix interpreter VMs from squeakvm.org. In your script you can do something like this: imagenumber=`ckformat myimage.image` if test $? -eq 0 then echo the image number is $imagenumber else echo could not read the image number fi If you are interested in the meanings of the various image format numbers, browse class ImageFormat. Dave
