COD3369 Posted October 9, 2012 Share Posted October 9, 2012 am making a automation script that regularly checks a specific folder for changes.. but I want to know that how we use can we check that file exsist on server or not. if exsist then download the file from server.. thank you Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 Welcome to AutoIt and the forum, is this a fileserver on an internal network or a server you access using TCP/IP (internet). It then depends on the services the server provides (FTP, HTTP). My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
COD3369 Posted October 9, 2012 Author Share Posted October 9, 2012 @water first of all thank you for quick reply , yes its ftp need to check using ftp. Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 Please check the FTP UDF in the help file, section User Defined Functions -> FTPEx. To check a file for existance you could use _FTP_FileGetSize. Doesn't put too much overhead on the server and the script and returns an error if the file doesn't exist. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
COD3369 Posted October 9, 2012 Author Share Posted October 9, 2012 can you please provide me a liitle code for it please I am newbie to autoit.. Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 (edited) Global $server = "servername or IP.address.of.your.server" Global $username = "usernmae" Global $pass = "password" Global $Open = _FTP_Open('MyFTP Control') Global $Conn = _FTP_Connect($Open, $server, $username, $pass) Global $FileSize = _FTP_FileGetSize($Conn, "your filename") Global $Ftpc = _FTP_Close($Open)Error checking has to be added by you Edited October 9, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
COD3369 Posted October 9, 2012 Author Share Posted October 9, 2012 thank you very much for this bro Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 Hope it works. Just did a q&d copy from the help file. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Mechaflash Posted October 9, 2012 Share Posted October 9, 2012 You're not getting a refund on that fish water =P Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 It's a start, so just half of a fish The OP still has to check the result of _FTP_FileGetSize and code the rest of the script. Error checking is also missing. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
VelvetElvis Posted October 11, 2012 Share Posted October 11, 2012 Global $server = "servername or IP.address.of.your.server" Global $username = "usernmae" Global $pass = "password" Global $Open = _FTP_Open('MyFTP Control') Global $Conn = _FTP_Connect($Open, $server, $username, $pass) Global $FileSize = _FTP_FileGetSize($Conn, "your filename") Global $Ftpc = _FTP_Close($Open)Error checking has to be added by you Looking for something like this myself. Changed this a wee bit to add a simple msgbox #include Global $server = "myserver" Global $username = "myusername" Global $pass = "mypassword" Global $Open = _FTP_Open('MyFTP Control') Global $Conn = _FTP_Connect($Open, $server, $username, $pass) Global $FileSize = _FTP_FileGetSize($Conn, "irreg.txt") ;Global $FileSize = _FTP_FileGetSize($Conn, "session.asp") If @error Then MsgBox(0, "", "Error: " & @error) Else MsgBox(0, "", $FileSize) EndIf Global $Ftpc = _FTP_Close($Open) Works great, except for zero-length files. I get the same error (-1) that I get for a non-existent file. Does anyone know an easy workaround? Link to comment Share on other sites More sharing options...
water Posted October 11, 2012 Share Posted October 11, 2012 (edited) If you get -1 you could try to read the file using $result = _FTP_FileRead($hFile, 1)I assume you get @error = -1 (End of file) and $result is set to "". If the file doesn't exist you should get another value for @error. Could you give this a try? Edited October 11, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
VelvetElvis Posted October 11, 2012 Share Posted October 11, 2012 If you get -1 you could try to read the file using $result = _FTP_FileRead($hFile, 1)I assume you get @error = -1 (End of file) and $result is set to "". If the file doesn't exist you should get another value for @error. Could you give this a try? OK using this code: $handle = _FTP_FileOpen($Conn, $filename) $result = _FTP_FileRead($handle, 1) MsgBox(0, "", "Error: " & @error & " Result: " & $result) - Empty file: Error -1 Result 0 - 80k text file: Error 0 Result 0x30 - Non-existant file: Error 2 Result 0 So it looks like if there's an empty file in the mix, I'm thinking it's probably better to forget this and read all the filenames via _FTP_ListToArray() and check for them there. Link to comment Share on other sites More sharing options...
COD3369 Posted October 12, 2012 Author Share Posted October 12, 2012 thank you guys:D Link to comment Share on other sites More sharing options...
water Posted October 12, 2012 Share Posted October 12, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now