SlimShady Posted May 10, 2004 Share Posted May 10, 2004 (edited) When I read this topic I felt like this is very useful.What this script does:Download files from your personal ftp/webserver to your home PC If you have scripts you're working on at work/school and want to run 'em: - You upload the scripts to the webserver - You edit the settings.ini to tell which script to download and run automaticallyDownload files from anywhere to your PC at homeFeatures:Any file you put in settings.ini will only download once.A logfile is createdAny file you want to download & run will only download & run once.By editing the ini file you can set n minutes to pause before checking for a new settings.ini. The settings.ini is downloaded infinite times and the script is run infinite times and pauses n minutes.By setting "Run=No" you can tell the script to not do anything until it says "Run=Yes".Settings.ini[Settings] Run=Yes Refresh=1 Website= DownloadFile=none DownloadUrl=none SaveDownloadAs=Run: can be Yes/No. Do something/do nothing.Refresh: number of minutes to pause before downloading the settings.iniWebsite: has to be a location where your settings.ini is enter the full URL including a slash at the endDownloadFile: Download & run a certain file from Website Required: If you want to disable this enter: none, else enter only a filename.DownloadUrl: a file that you want to download to your PC at home Required: If you want to disable this enter: none, else enter the full URL.SaveDownloadAs file name of the download DownloadUrl enter only a filename.If something goes terribly wrong, tell me. I don't expect it, I tested the script for an hour. It works like I wanted.Besides, if you want to download & run a certain file, you can add the delete function after the run command.Instructions:- Edit the settings.ini and set Run=No- Upload the settings.ini to a webserver or FTP server (manually)- Run the script on the PC where you save all your scripts and files- If you're at work/school, access the webserver or FTP server (manually) and download the settings.ini- Edit the ini file to your likings and upload it againIf you have suggestions, ideas. Please post it here.Thank you and have fun!expandcollapse popup;--------- Declare variables Global $Today, $Nextday, $Website, $Date $Date = @MON & "/" & @MDay $Folder = "C:\scripts\remote" $Temp = $Folder & "\temp" $Downloads = $Folder & "\Downloads" DirCreate($Folder) DirCreate($Temp) $CheckINI = @ScriptDir & "\settings.ini" $Logfile = $Folder & "\Logfile.txt" $NextDay = @MDAY + 1 $Today = @MON & "/" & @MDAY $NextDay = @MON & "/" & $NextDay Do URLDownloadToFile($Website & "settings.ini", $CheckINI) $Run = IniRead($CheckINI, "Settings", "Run", "") If $Run = "Yes" Then $Website = IniRead($CheckINI, "Settings", "Website", "") $DownloadFile = IniRead($CheckINI, "Settings", "DownloadFile", "") If $DownloadFile <> "none" Then $Extension = StringRight($DownloadFile, 4) $ProgramPath = $Temp & "\" & $DownloadFile Select Case $Extension = ".htm" Or $Extension = "html" $Program = "explorer " & $ProgramPath Case $Extension = ".ini" Or $Extension = ".txt" $Program = "notepad " & $ProgramPath Case $Extension = ".au3" $Program = "C:\Progra~1\AutoIt\AutoIt3.exe " & $ProgramPath Case $Extension = ".vbs" $Program = "wscript " & $ProgramPath EndSelect If Not FileExists($ProgramPath) Then URLDownloadToFile($Website & $DownloadFile, $ProgramPath) If FileExists($ProgramPath) Then $CurTime = @HOUR & ":" & @MIN $OpenLogfile = FileOpen($Logfile, 1) FileWriteLine($OpenLogfile, $Date & " " & $CurTime & " -> File downloaded from: " & $Website & $DownloadFile) FileClose($OpenLogfile) EndIf $CurTime = @HOUR & ":" & @MIN Run($Program) $OpenLogfile = FileOpen($Logfile, 1) FileWriteLine($OpenLogfile, $Date & " " & $CurTime & " -> File started: " & $DownloadFile) FileClose($OpenLogfile) EndIf EndIf $DownloadUrl = IniRead($CheckINI, "Settings", "DownloadUrl", "") If $DownloadUrl <> "none" Then DirCreate($Downloads) $SaveDownloadAs = IniRead($CheckINI, "Settings", "SaveDownloadAs", "") If Not FileExists($Downloads & "\" & $SaveDownloadAs) Then URLDownloadToFile($DownloadUrl, $Downloads & "\" & $SaveDownloadAs) $CurTime = @HOUR & ":" & @MIN $OpenLogfile = FileOpen($Logfile, 1) FileWriteLine($OpenLogfile, $Date & " " & $CurTime & " -> File downloaded from: " & $DownloadUrl) FileClose($OpenLogfile) EndIf EndIf EndIf $Extension = "" $Refresh = IniRead("C:\scripts\settings.ini", "Settings", "Refresh", "") $Refresh = Number($Refresh) Sleep($Refresh * 60 * 1000) Until $Today = $Nextday Exit Edited May 11, 2004 by SlimShady Link to comment Share on other sites More sharing options...
brett Posted May 10, 2004 Share Posted May 10, 2004 so, how would i log in to an FTP account with this so that the program can see the files? -Brett Link to comment Share on other sites More sharing options...
SlimShady Posted May 10, 2004 Author Share Posted May 10, 2004 Sorry, I forgot to add instructions. I will put them in the first post. Link to comment Share on other sites More sharing options...
brett Posted May 11, 2004 Share Posted May 11, 2004 OK, THIS IS HARD TO EXPLAIN, but i am going to make an attempt so that someone can help me.What i want to do is when the script inputs a command, it will go to a function where it checks to see if there are any new files in an FTP i created for file transfer between my home computer and a remote computer. When it receives the command, i want it to go toftp://username:password@hostname/and check to see if there are any new files. Or, if i could use a settings.ini file like in SlimShady's Script, that be even nicer. Then, i want the script to run it with the "yes" or "no" in slim's script.SlimShady, could i use your script above to do all of this?ThanksBrett -Brett Link to comment Share on other sites More sharing options...
SlimShady Posted May 11, 2004 Author Share Posted May 11, 2004 I tested it but it doesn't work. AutoIt can only download from a (http) webserver. BTW: there's a Select Case in my script where you can set the program paths for any filetype. You will have to change the path to AutoIt. Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted May 11, 2004 Share Posted May 11, 2004 Hmm? I have dled a txt file from ftp using urldltofile. Link to comment Share on other sites More sharing options...
Helge Posted May 11, 2004 Share Posted May 11, 2004 Hmm? I have dled a txt file from ftp using urldltofile.Ditto ! Link to comment Share on other sites More sharing options...
SlimShady Posted May 11, 2004 Author Share Posted May 11, 2004 Using ftp://username:password@hostname/ like Brett said?It didn't work here. Link to comment Share on other sites More sharing options...
Helge Posted May 11, 2004 Share Posted May 11, 2004 Using ftp://username:password@hostname/ like Brett said?It didn't work here.I can't remember the link I used.... Anyway...Just remember if you're using UrlDownloadToFile with a ftp-link (which contains username password),remember that there is a decompiler "out on the market" now...So if you share your script with anyone, you should keep in mind that it's not sohard for "them" to get their hands on your username and password..Even if the script is compiled !Just a little reminder..and warning ! Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted May 11, 2004 Share Posted May 11, 2004 (edited) I used ftp://user:pass@domain/file.exteg ftp://me:qwerty@ftp.tripod.com/blah.txtGood reminder there Helge, hadn't even crossed my mind.*editted cause I'm goin on 2 hours sleep heh* Edited May 11, 2004 by KnowledgeSponge Link to comment Share on other sites More sharing options...
SlimShady Posted May 11, 2004 Author Share Posted May 11, 2004 You could edit the ini file:Website=ftp://user:pass@domain/And it should work. If it doesn't, I can't help it.So my script downloads for example: ftp://user:pass@domain/settings.ini 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