How to execute a script from command line , then save the image and exit ?
I use the st command but it offers either --save which saves but keeps image opened or --exit the exits the image without saving ./pharo Ephestos.image st --save test.st |
2016-11-28 12:13 GMT+01:00 Dimitris Chloupis <[hidden email]>:
Use an option like -vm-display-null with -save. There is also a --nodisplay option. Thierry |
there are two binaries one is pharo-ui that displays the gui and one is pharo that does not use the GUI , because I use pharo and not pharo-ui , i do not need -vm-display-null and does not solve my problem of not exiting On Mon, Nov 28, 2016 at 1:25 PM Thierry Goubier <[hidden email]> wrote:
|
2016-11-28 12:54 GMT+01:00 Dimitris Chloupis <[hidden email]>:
Then this is strange because, as you remember from the Makefile (and because my line of work is command-line oriented), I use the pharo shell script to run a script and either save the image or not save the image, never opening the window in all cases. Thierry
|
can you provide a link to your makefile, maybe I do something stupid, I am very noob when it comes to command line cause I use GUIs 99% of the time On Mon, Nov 28, 2016 at 1:59 PM Thierry Goubier <[hidden email]> wrote:
|
The GitFileTree-MergeDriver is a good place for that since it has a Makefile[1] with smalltalk scripting inside ("eval"), and a command line handler[2] to handle being used on the command line[3] by git. [1] https://github.com/ThierryGoubier/GitFileTree-MergeDriver/blob/master/Makefile [2] https://github.com/ThierryGoubier/GitFileTree-MergeDriver/tree/master/GitFileTree-MergeDriver.package/GitFileTreeMergeCommandLine.class [3] https://github.com/ThierryGoubier/GitFileTree-MergeDriver/blob/master/merge 2016-11-28 13:01 GMT+01:00 Dimitris Chloupis <[hidden email]>:
|
In reply to this post by kilon.alios
Hi Dimitris,
According to STCommandLineHandler>>#end | quit | quit := self commandLine hasOption: 'quit'. (self commandLine hasOption: 'save') ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. quit ifTrue: [ self exitSuccess ]. You should be able to combine --quit and --save to get the desired effect but I haven't tested it. BTW, command line usage of Pharo works very well (and has been working well for years). Sven > On 28 Nov 2016, at 12:13, Dimitris Chloupis <[hidden email]> wrote: > > How to execute a script from command line , then save the image and exit ? > > I use the st command but it offers either --save which saves but keeps image opened or --exit the exits the image without saving > > ./pharo Ephestos.image st --save test.st |
I have been doing like this: #!/bin/bash ./pharo Pharo.image save Builder ./pharo Builder.image LoadBuilder.st --quit and LoadBuilder.st contains <code to load configurations and other thing> Smalltalk saveSession. Worked for me in a 3.0, so should still be fine. I could then to a set of images with various names and builders so one could have all the prerequisites and the last step just loaded my code fast on my CI. Phil On Mon, Nov 28, 2016 at 1:23 PM, Sven Van Caekenberghe <[hidden email]> wrote: Hi Dimitris, |
In reply to this post by Thierry Goubier
On Mon, Nov 28, 2016 at 2:13 PM Thierry Goubier <[hidden email]> wrote:
yeah problem is eval works fine for me too. " I have been doing like this: #!/bin/bash ./pharo Pharo.image save Builder ./pharo Builder.image LoadBuilder.st --quit and LoadBuilder.st contains <code to load configurations and other thing> Smalltalk saveSession. Worked for me in a 3.0, so should still be fine. I could then to a set of images with various names and builders so one could have all the prerequisites and the last step just loaded my code fast on my CI." Yeap that works but I found a nasty bug, pharo has issues when ! is contained inside a string so this code works ```Smalltalk Object subclass:#HelloWorld. HelloWorld class compile: 'run Transcript show: ''Hello World'' ;cr. Transcript show: ''Yes we did it again'' ;cr. ^self ' classified: #run. HelloWorld run. Smalltalk saveSession. ``` but this code produces an error if contained in a st file ```Smalltalk Object subclass:#HelloWorld. HelloWorld class compile: 'run Transcript show: ''Hello World'' ;cr. Transcript show: ''Yes we did it again!'' ;cr. ^self ' classified: #run. HelloWorld run. Smalltalk saveSession. ``` if the code is passed as eval it works fine. I assume here is because ! is used to define metadata inside a st file. |
2016-11-28 14:28 GMT+01:00 Dimitris Chloupis <[hidden email]>:
Yes, I'd guess that you are triggering the !! delimited reading when you give a .st. In short, giving a .st file as an argument triggers a FileIn operation, not an execute smalltalk script. It just happens that FileIn is an executable format (sort of), so you can use it as a script engine until you reach such issues. Thierry |
In reply to this post by Sven Van Caekenberghe-2
So… if I read that code correctly, when you pass both --save and --quit, the image will first save itself and quit (with an unspecified return code, or the one picked by the snapshot code). Then, next time you run this image, it will resume execution and exit immediately (that time with an explicit success return code). *¬_¬ not sure if stupid code or stupid me* On 28 November 2016 at 13:23, Sven Van Caekenberghe <[hidden email]> wrote: Hi Dimitris, |
> On 28 Nov 2016, at 15:08, Damien Pollet <[hidden email]> wrote: > > So… if I read that code correctly, when you pass both --save and --quit, the image will first save itself and quit (with an unspecified return code, or the one picked by the snapshot code). Then, next time you run this image, it will resume execution and exit immediately (that time with an explicit success return code). > > *¬_¬ not sure if stupid code or stupid me* Yeah, it does not add up, I think the last expression/test should not be there. This save&quit / resume is sometimes hard to reason about (BTW, I am looking at this in 4.0). > On 28 November 2016 at 13:23, Sven Van Caekenberghe <[hidden email]> wrote: > Hi Dimitris, > > According to > > STCommandLineHandler>>#end > | quit | > > quit := self commandLine hasOption: 'quit'. > > (self commandLine hasOption: 'save') > ifTrue: [ Smalltalk snapshot: true andQuit: quit ]. > > quit > ifTrue: [ self exitSuccess ]. > > You should be able to combine --quit and --save to get the desired effect but I haven't tested it. > > BTW, command line usage of Pharo works very well (and has been working well for years). > > Sven > > > On 28 Nov 2016, at 12:13, Dimitris Chloupis <[hidden email]> wrote: > > > > How to execute a script from command line , then save the image and exit ? > > > > I use the st command but it offers either --save which saves but keeps image opened or --exit the exits the image without saving > > > > ./pharo Ephestos.image st --save test.st > > > |
In reply to this post by Thierry Goubier
On Mon, Nov 28, 2016 at 3:43 PM Thierry Goubier <[hidden email]> wrote:
yeap and I found the solution a second ! escapes the first one :) so this strings creates an error 'Hello World!' but this one works fine 'Hello World!!' and prints Hello World! so that problem solved too :) |
Free forum by Nabble | Edit this page |