Comparing Versions
Posted
#1
(In Topic #1395)
Enthusiast

Just wanted to ask some advice
Does anyone know how I can get a application version without manually saving it to a text file?
What I want to do is save any new update to my central server and have a update app run once a day to check to see if the local version of the app is less then the one on the server if it is less then have the system wget the new file from my server and then rename the old one to .bak and move the new one to the location of the app and then start the app
I can reboot and restart my applications easily as I have a boot up script and this script does all the work.
Is it possible to access the version number from outside the app?
I.E My local version would be 6.0.1533 and the new one on the server would be 6.0.1599 so the system would download the file
and if the files are the other way wound the System would ignore the one on the server (example Server is 6.0.1533 and the Local one is 6.0.1599 (say I did the update to this manually)
I know this sound a bit random but I am hoping to automate the updates to my bug fixes on my Apps (The plan is so I don't have to keep connecting to customers machines at night and updating everything manually)
Any ideas or examples would be most welcomed.
Kind regards
Andy
Posted
Expert

If you check the box in project properties for { Get from 'VERSION' file. }
It creates a .version file in the project folder.
I'm assuming that this gets copied into the installation package ?
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast

Ive not worked out how to get a install package to work yet lol
I am not going down the wrong line of though for this am I? Maybe someone else has already though of a solution for this (if so I would love to hear it)
Posted
Guru

or add the arg yourself
or extract it from the .gambas executable .project file
<HIGHLIGHT highlight="shell">
eval "$(gba3 -x /path/to/MyProgram.gambas .project)"
echo $Version
</HIGHLIGHT>
Posted
Enthusiast

BruceSteers said
or extract it from the .gambas executable .project file
<HIGHLIGHT highlight="shell">
eval "$(gba3 -x /path/to/MyProgram.gambas .project)"
echo $Version
</HIGHLIGHT>
This is what I am after but I can not work out how to get the version from the Shell with in my update software
It works fine if I use the command terminal and type the commands you have given
I get the version 6.0.1577 (and this is correct)
if you have a example of how I can call these functions from a update app I would be most greatful
Code
Private Sub GetVersionFromDownloadedFile()
Dim ShellCommand As String = "eval $(gba3 -x RetailPoS.gambas .project)"
Dim Result As String
Shell ShellCommand To Result
Shell result & "$Version > retail.ver"
EndI can not seem to get working
I was thinking if I can get it to save to a txt file I can then get it to save to a veritable in the software so I can then do checks on the figures
below is my current tests I have done (i have changed the paths so they do not show my real server location)
Code
' Gambas class file
LocalFile As String = "/path/to/RetailPoS/RetailPoS.gambas"
NetFile As String = "http://webserver/update/RetailPoS/RetailPoS.gambas"
TempFolder As String = "/algPoS/Update/"
TempNet As String = TempFolder &/ "RetailPoS.gambas"
Public Sub Form_Open()
Try Kill TempNet 'Remove any old downloads that may have been missed (ie if app crashed)
End
Public Sub Button1_Click()
Label1.Caption = "Download file from server Please wait..."
copyFileToLocalDrive
GetVersionFromDownloadedFile
End
Private Sub copyFileToLocalDrive()
Dim ShellCommand As String = "wget -q " & NetFile & " -P " & TempFolder
Shell ShellCommand Wait
End
Private Sub GetVersionFromDownloadedFile()
Dim ShellCommand As String = "eval $(gba3 -x RetailPoS.gambas .project)"
Dim Result As String
Shell ShellCommand To Result
Shell result & "$Version > retail.ver"
End
Posted
Regular

b
Posted
Enthusiast

thatbruce said
Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b
Simple because I would forget to update the text file
I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update
Posted
Guru

Code (gambas)
also the eval command only runs the output for the .project file, like using source command.
within the output is a line like "Version=1.2.3" so it is like typing Version=1.2.3 in the terminal so it only sets the "$Version" variable but does not print anything, you need echo for that…
And echo must be with the same Shell command, another time you use Shell it will be a fresh process and the $Version variable is no longer there.
also you did not use full path for the project file just "gba3 -x RetailPoS.gambas" that probably will not do.
Code (gambas)
- ' use eval on gbx3 result and echo -n to print the $Version variable with no LF.
- ' Shell result & "$Version > retail.ver"
- ' maybe you mean something like this..
Posted
Guru

AndyGable said
thatbruce said
Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b
Simple because I would forget to update the text file
I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update
When you "Make executable" you can automatically run a command after.
It is set in the configure executable dialog…
once that line is set the Version.txt file will be automatically renewed every time you "make executable"
The only thing to watch out for is the Version.txt file it saves will be in the project directory but NOT in the executable because the command is run "after" the executable is made. (only my IDE also has a "Run Before" option)
If you need the Version.txt file inside your executable then you'll have to "make executable" twice for the same version and the second time will add the updated Version.txt file.
Posted
Enthusiast

BruceSteers said
AndyGable said
thatbruce said
Why not write out a small text file with the version (and possibly date/time) when you build the versions on both the local and server. The solution then becomes trivial (and the amount of transfer data to test for an update is a lot less).
b
Simple because I would forget to update the text file
I need this to be as idiot proof as I can make it so I don't break anything or customers break anything when systems update
When you "Make executable" you can automatically run a command after.
It is set in the configure executable dialog…
Untitled.png
The text i have set the in the "Run command after" writes the version text "0.0.1" with no LF to a file called Version.txt in the project dir.
once that line is set the Version.txt file will be automatically renewed every time you "make executable"
The only thing to watch out for is the Version.txt file it saves will be in the project directory but NOT in the executable because the command is run "after" the executable is made. (only my IDE also has a "Run Before" option)
If you need the Version.txt file inside your executable then you'll have to "make executable" twice for the same version and the second time will add the updated Version.txt file.
Thank for that
Andy
1 guest and 0 members have just viewed this.


