[Gambas-user] generating new gambas file [automatic program update]

Doriano Blengino doriano.blengino at ...1909...
Thu Sep 18 21:33:35 CEST 2008


Szenográdi Norbert Péter ha scritto:
> Hi All,
>
> Can I create a simple project with automatic update option?
> Well, when user starting a program, program will checking a new version
> from a portal etc.
> If new version possible change itself and restart a new version.
>
> This is possible?
>   
I think it is possible, althought it can be better to do it through a 
shell script.
Not sure about this, but you could do something like that:

    ' some code to determine if a new version is available
    shell "cd /tmp; wget http://your.server/updates/your-program.gambas" 
WAIT
    shell "mv /tmp/your-program.gambas /usr/local/bin/"   ' this rewrite 
the old executable
    shell "/usr/local/bin/your-program.gambas &"          ' two 
instances of the same program...
    quit


This snippet relies on a possibility that only *nix has - to [re]write a 
file while it is still in use (if it is).
Don't know if gambas interpreter keeps the file open while executing, 
but this should be ininfluent.
With the "shell ....&" you launch a second instance of the same program, 
which will be the updated file (bytecode).
Then the current application terminates.

There is a moment where two instances of the same application run 
concurrently, so
open files, or other system-wide resources, must be closed before doing 
that.


This is an overall idea - but it should work.

Regards





More information about the User mailing list