Updates silently before starting
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Updates silently before starting
I would like to have a program in Alaska, without any dialogue:
- Loads a specific file from the site or cloud;
- Launches them for execution.
Looked ftp clients with the launch from the command line, and download files from FTP using bat file, but it's not.
This module should compare the date of the program in the current folder on the server, and if the program is in the current folder, the latest version, then run it for execution, and if it is outdated, then download the new version from the server and run it.
May be more convenient to write such a startup file in a different language
- Loads a specific file from the site or cloud;
- Launches them for execution.
Looked ftp clients with the launch from the command line, and download files from FTP using bat file, but it's not.
This module should compare the date of the program in the current folder on the server, and if the program is in the current folder, the latest version, then run it for execution, and if it is outdated, then download the new version from the server and run it.
May be more convenient to write such a startup file in a different language
-
- Posts: 484
- Joined: Wed Jan 27, 2010 10:25 pm
- Location: Berlin Germany
Re: Updates silently before starting
This is no problem with XBase++ and a ftpclient (f.e. xb2.net).
_______________________
Best Regards
Wolfgang
Best Regards
Wolfgang
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Updates silently before starting
This is no problem for those who have xb2net, and who knows how to use it. And I do not belong either to the first or to the second. It is true I have a demo version sb2net and I saw all these clients, etc. But as far as to make a program like me away.
Re: Updates silently before starting
If you don't want a dialog window, put the following in your source code:
PROC appsys ; RETURN
PROC appsys ; RETURN
The eXpress train is coming - and it has more cars.
-
- Posts: 484
- Joined: Wed Jan 27, 2010 10:25 pm
- Location: Berlin Germany
Re: Updates silently before starting
Here is a function, that connects to a ftp server with xb2.net:
You can instead of downloading the file test, if it must be downloaded because of date, filesize etc.
If you are connected do a
The only difficulty here is to extract these data from the ftp-directory string, it looks f.e. like this (can be in another form on an other ftp-server):
Code: Select all
...
#include "xb2net.ch"
cGDServer:="download.....de"
Ftp_User:="???12345????"
Ftp_Passw:="********"
Ftp_File:="myprog.exe"
savepath:="C:\updates"
oFtp := XbFTPClient():new()
if oFtp:Connect(cGDServer)
if oFtp:Login(Ftp_User, Ftp_Passw)
oFtp:PassiveMode:=.T.
if oFtp:GetFile(Ftp_File, zielpath+"\"+Ftp_file)
else
...
endif
else
...
endif
else
...
endif
oFtp:close()
oFTP:destroy()
return
If you are connected do a
Code: Select all
aF:=oFtp:Directory()
for i:=1 to len(aF)
dname:=substr(aF[i],.....)
dsize:=val(alltrim(substr(aF[i],.....)))
cdate:=substr(aF[i],.....)
aadd(aFiles, { dname, dsize, ddate })
next
Code: Select all
*-rw-r----- 1 23441 nobody 4588600 Feb 21 10:33 myprog.exe
*-rw-r----- 1 23441 nobody 28883 Apr 5 15:08 LOGS.TXT
_______________________
Best Regards
Wolfgang
Best Regards
Wolfgang
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Updates silently before starting
It turned out to get full access to the site with a standard example of FTP-test of xb2net
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Updates silently before starting
Thank you so much! All well get up and running the way I wanted!
True, I have not yet done checking the file properties, but it is not difficult (with the texts I have a lot of experience). And yet there is one oddity: the downloaded file does not boot to the specified folder, and in the current, but I basically it should be.
Due to the fact that sb2net my demo in early jumps out a window, it will not work more than an hour, but I need just a few minutes. So this is though not beautiful, but large enough.
[/size]
Once again, thank you so much! Even yesterday, I could only dream
True, I have not yet done checking the file properties, but it is not difficult (with the texts I have a lot of experience). And yet there is one oddity: the downloaded file does not boot to the specified folder, and in the current, but I basically it should be.
Due to the fact that sb2net my demo in early jumps out a window, it will not work more than an hour, but I need just a few minutes. So this is though not beautiful, but large enough.
Code: Select all
#include "xb2net.ch"
#pragma Library("XB2NET.LIB")
PROCEDURE AppSys
// Рабочий стол остается окном приложения
RETURN
**************************************************************
FUNCTION MAIN()
DC_IconDefault(1000)
SET COLLATION TO SYSTEM // Руссификация
cGDServer:="http://lc.kubagro.ru"
Ftp_User:="*******"
Ftp_Passw:="******"
Ftp_File:="Downloads.exe"
savepath:="c:\Downloads\"
oFtp := XbFTPClient():new()
oFtp:PassiveMode := "/passive"
oFtp:SecureDataChannel:= "/securedata"
oFtp:RecvTimeout(10000)
oFtp:SendTimeout(10000)
IF oFtp:Connect(cGDServer)
IF oFtp:Login(Ftp_User, Ftp_Passw)
oFtp:PassiveMode:=.T.
IF oFtp:GetFile(Ftp_File, "Downloads.exe")
* LB_Warning('Start and update System "Aidos-X++"', '(C) System "Aidos-X++"' )
ELSE
LB_Warning('Update file can not be found on the FTP server', '(C) System "Aidos-X++"')
ENDIF
ELSE
LB_Warning('Authorization error with the FTP server', '(C) System "Aidos-X++"' )
ENDIF
ELSE
LB_Warning('Error connecting to FTP server', '(C) System "Aidos-X++"' )
ENDIF
oFtp:close()
oFTP:destroy()
*** If the update file is newer installed on your computer system, then deploy it, otherwise just run the system
RunShell("","Downloads.exe",.T.)
RunShell("","_aidos-x.exe",.T.)
RETURN NIL
****************************************
FUNCTION LB_Warning( message, ctitle )
LOCAL aMsg := {}
* DEFAULT cTitle TO ''
IF valtype(message) # 'A'
aadd(aMsg,message)
ELSE
aMsg := message
ENDIF
IF LEN(ALLTRIM(cTitle)) > 0
DC_MsgBox( ,,aMsg,cTitle)
ELSE
DC_MsgBox( ,,aMsg, '(C) system "Aidos-X++"' )
ENDIF
RETURN NIL
Once again, thank you so much! Even yesterday, I could only dream
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Updates silently before starting
That seems to do as he wanted. But there are two questions.
1 How to make the following command for RunShell ("", "Downloads.exe",. F.) Was not performed until it is over?
2 Demo sb2net not only throws out the window at the beginning and does not work for more than 60 minutes, but still not download files larger than 3 MB?
3. How can I make this program after starting the main program itself ended after a specified time?
4 If you are loading a large file, you probably still want to show the loading step. How to do it?
Thank you so much for your support
[/size]
1 How to make the following command for RunShell ("", "Downloads.exe",. F.) Was not performed until it is over?
2 Demo sb2net not only throws out the window at the beginning and does not work for more than 60 minutes, but still not download files larger than 3 MB?
3. How can I make this program after starting the main program itself ended after a specified time?
4 If you are loading a large file, you probably still want to show the loading step. How to do it?
Thank you so much for your support
Code: Select all
#include "xb2net.ch"
#pragma Library("XB2NET.LIB")
PROCEDURE AppSys
// Рабочий стол остается окном приложения
RETURN
**************************************************************
FUNCTION MAIN()
DC_IconDefault(1000)
SET COLLATION TO SYSTEM // Русификация
SET DATE GERMAN
CrLf = CHR(13)+CHR(10) // Конец строки (записи)
*** Flag = 0. Что-то вообще не то
*** Flag = 1. Если в текущей папке исполнимого файла системы нет, то скачивание и разархивирование полного архива и запуск системы на исполнение
*** Если в текущей папке исполнимый файл системы есть, то
*** проверка дат создания файла системы и файла обновлений
*** Flag = 2. Если система устарела - скачивание обновлений и запуск новой версии системы
*** Flag = 3. Иначе - запуск существующей версии системы
Flag = 0
mCountSys = ADIR("_aidos-x.exe")
IF mCountSys = 0 // В текущей папке исполнимого файла системы нет
Flag = 1
ELSE
PRIVATE aName[1], aSize[1], aDate[1]
mCountSys = ADIR("_aidos-x.exe", aName, aSize, aDate )
mDateSys = aDate[1]
StrFile(DTOC(aDate[1]), "DateSys.txt") // Запись текстового файла с датой создания исполнимого модуля системы
ENDIF
cGDServer:="http://lc.kubagro.ru"
Ftp_User:="*********"
Ftp_Passw:="********"
Ftp_File:="Downloads.exe"
*savepath:="c:\Downloads\"
oFtp := XbFTPClient():new()
IF oFtp:Connect(cGDServer) // Соединение
IF oFtp:Login(Ftp_User, Ftp_Passw) // Авторизация
oFtp:PassiveMode:=.T. // Пассивный режим
// Flag = 1. Если в текущей папке исполнимого файла системы нет, то скачивание и разархивирование полного архива и запуск системы на исполнение
IF Flag = 1
IF oFtp:GetFile(Ftp_File, "Aidos-x.exe")
* LB_Warning('Start and update System "Aidos-X++"', '(C) System "Aidos-X++"' )
ELSE
LB_Warning('Update file can not be found on the FTP server', '(C) System "Aidos-X++"')
ENDIF
ELSE
***** Проверка времени создания файла обновлений без его скачивания прямо на FTP-сервере
aFileUpd:=oFtp:Directory("Downloads.exe")
mDateUpd = CTOD(SUBSTR(aFileUpd[1], 4, 2) + "." + SUBSTR(aFileUpd[1], 1, 2) + ".20" + SUBSTR(aFileUpd[1], 7, 2))
StrFile(DTOC(mDateUpd), "DateUpd.txt") // Запись текстового файла параметров файла обновлений
** Flag = 2. Если система устарела - скачивание обновлений и запуск новой версии системы
IF mDateSys < mDateUpd // Исполнимый файл системы в текущей папке старее файла обновлений
IF oFtp:GetFile(Ftp_File, "Downloads.exe") // Скачивание файла обновлений
* LB_Warning('Start and update System "Aidos-X++"', '(C) System "Aidos-X++"' )
Flag = 2 // Система устарела, надо скачать и развернуть обновления
ELSE
LB_Warning('Update file can not be found on the FTP server', '(C) System "Aidos-X++"')
ENDIF
ELSE
Flag = 3 // Система не устарела, просто запустить ее
ENDIF
ENDIF
ELSE
LB_Warning('Authorization error with the FTP server', '(C) System "Aidos-X++"' )
ENDIF
ELSE
LB_Warning('Error connecting to FTP server', '(C) System "Aidos-X++"' )
ENDIF
oFtp:close()
oFTP:destroy()
*** Если файл обновлений новее установленной на компьютере системы, то развернуть его, иначе просто запустить систему
DO CASE
CASE Flag = 0 // Что-то не то
LB_Warning('Error! Error! Error! Error!', '(C) System "Aidos-X++"' )
CASE Flag = 1 // Flag = 1. Если в текущей папке исполнимого файла системы нет, то скачивание и разархивирование полного архива и запуск системы на исполнение
RunShell("","Aidos-x.exe",.F.) // Полный архив - инсталляция
RunShell("","_aidos-x.exe",.F.) // Исполнимый файл системы
CASE Flag = 2 // Flag = 2. Если система устарела - скачивание обновлений и запуск новой версии системы
RunShell("","Downloads.exe",.F.)
RunShell("","_aidos-x.exe",.F.)
CASE Flag = 3 // Flag = 3. Запуск существующей версии системы
RunShell("","_aidos-x.exe",.F.)
ENDCASE
RETURN NIL
******************************************************************
*** Проверка свойств файлов без их скачивания прямо на FTP-сервере
******************************************************************
*aF:=oFtp:Directory()
*for i:=1 to len(aF)
* dname:=substr(aF[i],.....)
* dsize:=val(alltrim(substr(aF[i],.....)))
* cdate:=substr(aF[i],.....)
* aadd(aFiles, { dname, dsize, ddate })
*next
****************************************
FUNCTION LB_Warning( message, ctitle )
LOCAL aMsg := {}
* DEFAULT cTitle TO ''
IF valtype(message) # 'A'
aadd(aMsg,message)
ELSE
aMsg := message
ENDIF
IF LEN(ALLTRIM(cTitle)) > 0
DC_MsgBox( ,,aMsg,cTitle)
ELSE
DC_MsgBox( ,,aMsg, '(C) system "Aidos-X++"' )
ENDIF
RETURN NIL
Re: Updates silently before starting
Your questions don't translate well for me.
Please clarify.
Please clarify.
The eXpress train is coming - and it has more cars.
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Updates silently before starting
Hi, Roger!
The main question is how to make sure that the commands following RunShell ("", "Downloads.exe" ,. F.), were not met until this command is not finished. For example, the file: Downloads.ehe - a self-extracting archive. He starts to unzip, and the next team RunShell ("", "_Aidos.exe" ,. F.) executes the following file _Aidos.ehe, which is in the archive, but has not yet appeared as a result of unzipping because it even before he realized. There is a runtime error with the options: "Undo", "Redo". If you wait until the file _Aidos.ehe appears and select "Repeat", then everything works fine. But it would be better (in this case), the following command would simply have not been performed until the completion of the previous one.
The main question is how to make sure that the commands following RunShell ("", "Downloads.exe" ,. F.), were not met until this command is not finished. For example, the file: Downloads.ehe - a self-extracting archive. He starts to unzip, and the next team RunShell ("", "_Aidos.exe" ,. F.) executes the following file _Aidos.ehe, which is in the archive, but has not yet appeared as a result of unzipping because it even before he realized. There is a runtime error with the options: "Undo", "Redo". If you wait until the file _Aidos.ehe appears and select "Repeat", then everything works fine. But it would be better (in this case), the following command would simply have not been performed until the completion of the previous one.