Sign in to follow this  
Followers 0
b0ris

Check the version of a file on an FTP server

7 posts in this topic

Hi there!

I'm trying to check out the version of a file on an ftp server, but can't think of a way to do it. I've also searched the forum, and googled a bit, but found nothing.

The main idea is that I'm creating a binary with autoit, incrementing the file version every time I'm changin something, then I'll upload it on the server. If someone starts this application, it should automatically check if there's a newer version, and download it from this FTP server if there is. In other words, it's an auto-update thingy.

So do you guys know how to do this, or do you have any idea for another auto-update procedure?

All suggestions are welcome, thanks in advance.

Share this post


Link to post
Share on other sites

The simplest I see is append the version to the FTP serveur filename. Make it ABCD.exe.v3_3_6_1 and strip the last part to write ABCD.exe to the client disk.

Use leading zeroes if needed to avoid unexpected results (i.e. v3_3_9 "older" than v3_3_10; use v3_3_09)


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

The simplest I see is append the version to the FTP serveur filename. Make it ABCD.exe.v3_3_6_1 and strip the last part to write ABCD.exe to the client disk.

Use leading zeroes if needed to avoid unexpected results (i.e. v3_3_9 "older" than v3_3_10; use v3_3_09)

Thanks jchd, good idea, I'll try to do that somehow, as I still can't figure a better one.

If someone's got an even better idea, it would be more than welcome.

Share this post


Link to post
Share on other sites

That or put a second file to that effect along the executable. The version can be the filename itself or written in the file.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

That or put a second file to that effect along the executable. The version can be the filename itself or written in the file.

I've done that, thank you for your help!

Have a good day!

Share this post


Link to post
Share on other sites

Hi there!

I'm trying to check out the version of a file on an ftp server, but can't think of a way to do it. I've also searched the forum, and googled a bit, but found nothing.

The main idea is that I'm creating a binary with autoit, incrementing the file version every time I'm changin something, then I'll upload it on the server. If someone starts this application, it should automatically check if there's a newer version, and download it from this FTP server if there is. In other words, it's an auto-update thingy.

So do you guys know how to do this, or do you have any idea for another auto-update procedure?

All suggestions are welcome, thanks in advance.

It's a bit of a long way around but check out.

#include <FTPEx.au3>
#include <Array.au3>

$server = ''
$username = ''
$pass = ''
$directory = "/"

$Open = _FTP_Open('MyFTP Control')
$Conn = _FTP_Connect($Open, $server, $username, $pass)
_FTP_DirSetCurrent($Conn, $directory)

$aFile = _FTP_ListToArrayEx($Conn, 2,0,0)
;Parameters
;$l_FTPSession as returned by _FTP_Connect().
;$Return_type [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
;$l_Flags [optional] see _FTP_FindFileFirst().
;$b_Fmt [optional] type on the date strings : 1 = yyyy/mm/dd, 0 = mm/dd/yyyy.
;$l_Context [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.
If $aFile[0][0] = 0 Then
    MsgBox(0,"ERROR: _FTP_ListToArrayEx","command failed")
Else
    ConsoleWrite('array count = ' & UBound($aFile)& '  -> Error code: ' & @error & @CRLF)
    _ArrayDisplay($aFile)
EndIf

;ConsoleWrite('$Filename = ' & $aFile[1] & @crlf)

$Ftpc = _FTP_Close($Open)

It's not a solution (and it's junk code) but may give you a pointer to a solution.

Array returned from _FTP_ListToArrayEx

Array[0][0] = number of found entries

Array[x][0] Filename
Array[x][1] Filesize
Array[x][2] FileAttribute
Array[x][3] File Modification datetime
Array[x][4] File Creation datetime
Array[x][5] File Access datetime

All you need to do is to search through the array for the right file then get the "modified" date.

If you come up with a full solution let us know.

Good Luck!

Share this post


Link to post
Share on other sites

It's a bit of a long way around but check out.

#include <FTPEx.au3>
#include <Array.au3>

$server = ''
$username = ''
$pass = ''
$directory = "/"

$Open = _FTP_Open('MyFTP Control')
$Conn = _FTP_Connect($Open, $server, $username, $pass)
_FTP_DirSetCurrent($Conn, $directory)

$aFile = _FTP_ListToArrayEx($Conn, 2,0,0)
;Parameters
;$l_FTPSession as returned by _FTP_Connect().
;$Return_type [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
;$l_Flags [optional] see _FTP_FindFileFirst().
;$b_Fmt [optional] type on the date strings : 1 = yyyy/mm/dd, 0 = mm/dd/yyyy.
;$l_Context [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.
If $aFile[0][0] = 0 Then
    MsgBox(0,"ERROR: _FTP_ListToArrayEx","command failed")
Else
    ConsoleWrite('array count = ' & UBound($aFile)& '  -> Error code: ' & @error & @CRLF)
    _ArrayDisplay($aFile)
EndIf

;ConsoleWrite('$Filename = ' & $aFile[1] & @crlf)

$Ftpc = _FTP_Close($Open)

It's not a solution (and it's junk code) but may give you a pointer to a solution.

Array returned from _FTP_ListToArrayEx

Array[0][0] = number of found entries

Array[x][0] Filename
Array[x][1] Filesize
Array[x][2] FileAttribute
Array[x][3] File Modification datetime
Array[x][4] File Creation datetime
Array[x][5] File Access datetime

All you need to do is to search through the array for the right file then get the "modified" date.

If you come up with a full solution let us know.

Good Luck!

Thank you, it seems like a good way to do what I want, however I've already found another solution, which is not the best, but works perfectly, and it's fast. I'm checking the file version on the user's computer with FileGetVersion, and compare it with a string which I'm storing in a table on a MySQL server. I found that this is the fastest way to compare the file version, and speed is why I'm updating my original autoupdate code.

Thank you all again for trying to help me, I really appreciate it. If I find a better solution for the above, I'll post it here, or in the examples topic.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0