Command Line Squeak/Scripting: Status?

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

Command Line Squeak/Scripting: Status?

Aaron Reichow-2
Hi everyone!

I'm curious about what the status of a Squeak setup for scripting is,  
specifically for Linux?  My end goal is being able to tell a user or  
run programmatically from another script a Squeak script by typing  
something like:

./hallowelt.sq

where hallowelt.sq is a file like-

#!/usr/bin/squeak -filein
Transcript show: 'Hello World'; cr.

I also would really, really like, the ability to pass command line  
arguments, so:

./hallowelt2.sq Aaron

#!/usr/bin/squeak -filein
Transcript show: 'Hello World ';
        show: (Argv at: 2);
        cr.


I don't need anything very fancy, nor do I need a certain version of  
the image or much in the way of library support. The one library I do  
need is PostgreSQL suport.  In my newish job, I'm starting to move  
various reports that pull data from a super flexible object-
relational database setup from Java to Python. I'd like to do this in  
Squeak, obviously! But due to a few factors, the first couple I've  
done are in Python.  I don't need to do any elaborate stuff, I don't  
need a curses interface, etc. I'm fine with most of it all being in  
the image, with the hallowelt.sq file in this example being nothing  
other than something that runs the squeak VM but some how tells the  
image to run a certain script through a command line argument.   I'd  
do development on a regular Squeak VM on my Mac, then deploy to the  
server where someone else would run the reports.

Worst case I could roll this myself, skipping commandline arguments  
and using config files that the report-runner has to edit to specify  
the date range rather than just doing it on the command line. But I'd  
rather a more Unix-feeling solution. I personally don't need anything  
like input and output through pipes, but I might find a use for them  
later if the option was there.

So, what's up with Squeak for this sort of setup? What are my  
options? Do I have any useable ones?

Regards,
Aaron

Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

Jon Hylands
On Fri, 9 Feb 2007 02:53:25 -0600, Aaron Reichow <[hidden email]>
wrote:

> So, what's up with Squeak for this sort of setup? What are my  
> options? Do I have any useable ones?

You can pass (and access) command line arguments in squeak - I do it all
the time in my headless images.

Look at implementers of #getSystemAttribute:

This is what the beginning of my startup method (class-side) looks like:

startUp: resuming

        | parameter |
        resuming
                ifFalse: [^self].

        parameter := Smalltalk getSystemAttribute: 2.
        parameter isNil
                ifTrue: [^self].

        parameter asLowercase = '-runmission'
                ifTrue: [
                        self runMission.
                        Smalltalk quitPrimitive].

        ...

Then you need to register whatever class that method is implemented in:

initialize

        Smalltalk addToStartUpList: self

Run the initialize method, and then save and quit.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      [hidden email]      http://www.huv.com/jon

  Project: Micro Raptor (Small Biped Velociraptor Robot)
           http://www.huv.com/blog

Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

stephane ducasse
In reply to this post by Aaron Reichow-2
Mathieu should release sapphire soon but he got a tooth problem.
And I would love to have clients that complain :)

Stef

> Hi everyone!
>
> I'm curious about what the status of a Squeak setup for scripting  
> is, specifically for Linux?  My end goal is being able to tell a  
> user or run programmatically from another script a Squeak script by  
> typing something like:
>
> ./hallowelt.sq
>
> where hallowelt.sq is a file like-
>
> #!/usr/bin/squeak -filein
> Transcript show: 'Hello World'; cr.
>
> I also would really, really like, the ability to pass command line  
> arguments, so:
>
> ./hallowelt2.sq Aaron
>
> #!/usr/bin/squeak -filein
> Transcript show: 'Hello World ';
> show: (Argv at: 2);
> cr.
>
>
> I don't need anything very fancy, nor do I need a certain version  
> of the image or much in the way of library support. The one library  
> I do need is PostgreSQL suport.  In my newish job, I'm starting to  
> move various reports that pull data from a super flexible object-
> relational database setup from Java to Python. I'd like to do this  
> in Squeak, obviously! But due to a few factors, the first couple  
> I've done are in Python.  I don't need to do any elaborate stuff, I  
> don't need a curses interface, etc. I'm fine with most of it all  
> being in the image, with the hallowelt.sq file in this example  
> being nothing other than something that runs the squeak VM but some  
> how tells the image to run a certain script through a command line  
> argument.   I'd do development on a regular Squeak VM on my Mac,  
> then deploy to the server where someone else would run the reports.
>
> Worst case I could roll this myself, skipping commandline arguments  
> and using config files that the report-runner has to edit to  
> specify the date range rather than just doing it on the command  
> line. But I'd rather a more Unix-feeling solution. I personally  
> don't need anything like input and output through pipes, but I  
> might find a use for them later if the option was there.
>
> So, what's up with Squeak for this sort of setup? What are my  
> options? Do I have any useable ones?
>
> Regards,
> Aaron
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

J J-6

What is Sapphire?  I haven't heard of this one.  Didn't see it on google or
squeaksource either.

>From: stephane ducasse <[hidden email]>
>Reply-To: The general-purpose Squeak developers
>list<[hidden email]>
>To: The general-purpose Squeak developers
>list<[hidden email]>
>Subject: Re: Command Line Squeak/Scripting: Status?
>Date: Fri, 9 Feb 2007 15:30:14 +0100
>
>Mathieu should release sapphire soon but he got a tooth problem.
>And I would love to have clients that complain :)
>
>Stef
>
>>Hi everyone!
>>
>>I'm curious about what the status of a Squeak setup for scripting  is,
>>specifically for Linux?  My end goal is being able to tell a  user or run
>>programmatically from another script a Squeak script by  typing something
>>like:
>>
>>./hallowelt.sq
>>
>>where hallowelt.sq is a file like-
>>
>>#!/usr/bin/squeak -filein
>>Transcript show: 'Hello World'; cr.
>>
>>I also would really, really like, the ability to pass command line  
>>arguments, so:
>>
>>./hallowelt2.sq Aaron
>>
>>#!/usr/bin/squeak -filein
>>Transcript show: 'Hello World ';
>> show: (Argv at: 2);
>> cr.
>>
>>
>>I don't need anything very fancy, nor do I need a certain version  of the
>>image or much in the way of library support. The one library  I do need is
>>PostgreSQL suport.  In my newish job, I'm starting to  move various
>>reports that pull data from a super flexible object- relational database
>>setup from Java to Python. I'd like to do this  in Squeak, obviously! But
>>due to a few factors, the first couple  I've done are in Python.  I don't
>>need to do any elaborate stuff, I  don't need a curses interface, etc. I'm
>>fine with most of it all  being in the image, with the hallowelt.sq file
>>in this example  being nothing other than something that runs the squeak
>>VM but some  how tells the image to run a certain script through a command
>>line  argument.   I'd do development on a regular Squeak VM on my Mac,  
>>then deploy to the server where someone else would run the reports.
>>
>>Worst case I could roll this myself, skipping commandline arguments  and
>>using config files that the report-runner has to edit to  specify the date
>>range rather than just doing it on the command  line. But I'd rather a
>>more Unix-feeling solution. I personally  don't need anything like input
>>and output through pipes, but I  might find a use for them later if the
>>option was there.
>>
>>So, what's up with Squeak for this sort of setup? What are my  options? Do
>>I have any useable ones?
>>
>>Regards,
>>Aaron
>>
>>
>
>

_________________________________________________________________
Valentine’s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping
http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline


Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

Philippe Marschall
2007/2/9, J J <[hidden email]>:
>
> What is Sapphire?  I haven't heard of this one.  Didn't see it on google or
> squeaksource either.

http://www.squeaksource.com/Saphir.html

> >From: stephane ducasse <[hidden email]>
> >Reply-To: The general-purpose Squeak developers
> >list<[hidden email]>
> >To: The general-purpose Squeak developers
> >list<[hidden email]>
> >Subject: Re: Command Line Squeak/Scripting: Status?
> >Date: Fri, 9 Feb 2007 15:30:14 +0100
> >
> >Mathieu should release sapphire soon but he got a tooth problem.
> >And I would love to have clients that complain :)
> >
> >Stef
> >
> >>Hi everyone!
> >>
> >>I'm curious about what the status of a Squeak setup for scripting  is,
> >>specifically for Linux?  My end goal is being able to tell a  user or run
> >>programmatically from another script a Squeak script by  typing something
> >>like:
> >>
> >>./hallowelt.sq
> >>
> >>where hallowelt.sq is a file like-
> >>
> >>#!/usr/bin/squeak -filein
> >>Transcript show: 'Hello World'; cr.
> >>
> >>I also would really, really like, the ability to pass command line
> >>arguments, so:
> >>
> >>./hallowelt2.sq Aaron
> >>
> >>#!/usr/bin/squeak -filein
> >>Transcript show: 'Hello World ';
> >>      show: (Argv at: 2);
> >>      cr.
> >>
> >>
> >>I don't need anything very fancy, nor do I need a certain version  of the
> >>image or much in the way of library support. The one library  I do need is
> >>PostgreSQL suport.  In my newish job, I'm starting to  move various
> >>reports that pull data from a super flexible object- relational database
> >>setup from Java to Python. I'd like to do this  in Squeak, obviously! But
> >>due to a few factors, the first couple  I've done are in Python.  I don't
> >>need to do any elaborate stuff, I  don't need a curses interface, etc. I'm
> >>fine with most of it all  being in the image, with the hallowelt.sq file
> >>in this example  being nothing other than something that runs the squeak
> >>VM but some  how tells the image to run a certain script through a command
> >>line  argument.   I'd do development on a regular Squeak VM on my Mac,
> >>then deploy to the server where someone else would run the reports.
> >>
> >>Worst case I could roll this myself, skipping commandline arguments  and
> >>using config files that the report-runner has to edit to  specify the date
> >>range rather than just doing it on the command  line. But I'd rather a
> >>more Unix-feeling solution. I personally  don't need anything like input
> >>and output through pipes, but I  might find a use for them later if the
> >>option was there.
> >>
> >>So, what's up with Squeak for this sort of setup? What are my  options? Do
> >>I have any useable ones?
> >>
> >>Regards,
> >>Aaron
> >>
> >>
> >
> >
>
> _________________________________________________________________
> Valentine's Day -- Shop for gifts that spell L-O-V-E at MSN Shopping
> http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

Brent Fulgham
In reply to this post by Aaron Reichow-2
> >>I'm curious about what the status of a Squeak setup for scripting  is,
> >>specifically for Linux?  My end goal is being able to tell a  user or run
> >>programmatically from another script a Squeak script by  typing something

If one of these functions well enough to run programs from a script, let me know
and I'll be glad to add Squeak to the "Computer Language Shootout"
(http://shootout.alioth.debian.org).

If need be, we can generate a squeak image with the benchmark classes in it,
save the image, and run the script using the image.  We do this for the Lisp
and GNU Smalltalk implementations.

-Brent




Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

Mathieu SUEN
In reply to this post by Philippe Marschall
Thanks Philippe,

For the time being you can use it but if you want to use the shell  
you have to compile or get the OSProcess plugin.
However, on bug still remains when you declare classes. So, if you  
want to define method the class should be already in the image.

I hope I can fix it this weekend and build a little web page to  
explain how to use it. Then I will give you the link to some pre-
prepared image .


        Math


On Feb 9, 2007, at 8:23 PM, Philippe Marschall wrote:

> 2007/2/9, J J <[hidden email]>:
>>
>> What is Sapphire?  I haven't heard of this one.  Didn't see it on  
>> google or
>> squeaksource either.
>
> http://www.squeaksource.com/Saphir.html


Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

Lex Spoon-3
In reply to this post by Brent Fulgham
Brent Fulgham <[hidden email]> writes:

> > >>I'm curious about what the status of a Squeak setup for scripting  is,
> > >>specifically for Linux?  My end goal is being able to tell a  user or run
> > >>programmatically from another script a Squeak script by  typing something
>
> If one of these functions well enough to run programs from a script, let me know
> and I'll be glad to add Squeak to the "Computer Language Shootout"
> (http://shootout.alioth.debian.org).

Try "man squeak", or on Debian, "man squeakvm".  There are
instructions on how to do it down under the "Scripts" section.

The simplest thing is to make a file with the Smalltalk code and then
another script that has:

  squeak squeak.image thescript.st

However, you can also make self-contained script files.  Here's a
simple example fromthe man page, though I'm sure with some cleverness
you can come up with more ideas.

              #!/usr/bin/squeakvm --
              Transcript cr; show: ’Hello, world’.


Now, this basically all works, but be warned that there are a lot of
rough edges.  Nobody programs like this, and so nobody has polished
it.  For example, the last time I checked, error messages are not
handled gracefully.


-Lex


Reply | Threaded
Open this post in threaded view
|

Re: Command Line Squeak/Scripting: Status?

keith1y
And in 3.9 thescript.st has to have the full path or url to the file.
>   squeak squeak.image thescript.st
>
>  
Keith

               
___________________________________________________________
All New Yahoo! Mail �Tired of Vi@gr@! come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html