greenkev Posted April 25, 2013 Posted April 25, 2013 Hello everyone, I'm starting with the AutoIt language which is why I need your help. I'm looking for a script that would make a connection to an FTP site to retrieve a file. Zip. This script is based on a config file that will contain four values (ftp site, login, password and the source file that I need to recover). The script will, once downloaded, unzip the folder in a specific way that will be considered in a fifth value (destination --> C:\_SOURCES). It would be great to have a progress bar to see the progress of the recovery folder. Zip. Thank you in advance for your help. greenkev
Vincor Posted April 25, 2013 Posted April 25, 2013 Hi greenkevYou can find all that in the help file, wiki and forum discussions:FTP'ing: http://www.autoitscript.com/autoit3/docs/functions/InetGet.htmZIP'ing: Progress bar: http://www.autoitscript.com/wiki/Progress_Bar_SampleTry and put these samples together, and you'll have your script.Good luck!
greenkev Posted April 25, 2013 Author Posted April 25, 2013 Thank you for your answer, i appreciated it . I'm obliged to create 2 files or only file with all contents ?
Vincor Posted April 25, 2013 Posted April 25, 2013 You are not bound to any number of files. If you use functions from another file, just remember to "include" it. What I meant with putting them together was to see how each of these features worked, and then write your own script (probably enhancing one of the examples there).By the way, regarding the config file you mentioned, the easiest would be an INI file (http://www.autoitscript.com/autoit3/docs/functions/IniRead.htm)There are many good script examples in the forum - try the forum search.
greenkev Posted April 26, 2013 Author Posted April 26, 2013 I'm a real newbie. I don't succeed to create this script and persons told me that is easy.
Vincor Posted April 26, 2013 Posted April 26, 2013 And it is easy indeed.Well, if you don't have any experience scripting in any other language, then you need to learn the basics. Next steps from here are:1) Take one of the AutoIt tutorials (http://www.autoitscript.com/wiki/Tutorials). Great stuff there, also for new beginners.2) If you are still stuck after that, post your script here, so people have a better chance of helping you.Good luck!
greenkev Posted April 26, 2013 Author Posted April 26, 2013 Ok thanks . I begin my script like this : expandcollapse popup#include #include #include #include #include #include #include ;Variables ;ftp_site Global $server = 'ftp_site' ; name of folder for 7zip --> Everybody can help me to install 7zip portable in this script Global $7zip = "7zip" ;fisrt user Global $usernamenan = 'user1' ;second user Global $usernamegf = 'user2' ;third user Global $usernamegrh = 'user3' ;fourth user Global $usernamepel = 'user4' ;password for the first user Global $passwordnan = 'password1' ;password for the second user Global $passwordgf = 'password2' ;password for the third user Global $passwordgrh = 'password3' ;password for the fourth user Global $passwordpel = 'password4' ;file to recover in ftp site Global $source = '/name_of_file_to_recover_in_ftp_site.zip' ;default system drive Global $sysdrive=EnvGet("SystemDrive") ; To download the file Local $hDownload = InetGet("ftp://user:password@ftp_site/name_of_file_to_recover_in_ftp_site", @DesktopDir & "\name_of_file_recupered_in_ftp_site", 1, 1) ; Size of the file in ftp site Local $nSize = InetGetSize("ftp://user:password@site_ftp/name_of_file_to_recover_in_ftp_site") MsgBox(0, "Taille du fichier en Octets:", $nSize) ;Progress Bar HotKeySet("{ESC}", "endscript") local $m = 1 GUICreate("Install in progress ...", 252, 25,-1,-1,$WS_CAPTION) GuiCtrlCreateGraphic(1, 5, 250,15) GUICtrlSetColor(-1, 0x000000) $ba = GuiCtrlCreateGraphic(1, 6, 49,13) GUICtrlSetBkColor($ba, 0x0FF000) GuiSetState() _SliderRight() Func _SliderRight() For $m = 0 To 201 Step 3 GUICtrlSetPos($ba, $m, 6, 49, 13) Sleep(50) Next _getmsg() _SliderLeft() EndFunc ;==>_SliderRight Func _SliderLeft() For $m = 201 To 0 Step -3 GUICtrlSetPos($ba, $m, 6, 49, 13) Sleep(60) Next _getmsg() _SliderRight() EndFunc ;==>_SliderLeft Func _getmsg() $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit --> I don't know that it must be write here to close the loop EndFunc ;==>_getmsg Func endscript() Exit EndFunc ;==>endscript
Vincor Posted April 26, 2013 Posted April 26, 2013 That's a start. Put the GUI and progress bar aside until you understand what is happening in your script. That is just on your way right now. I see no reason for so many different users, empty "includes" and other unused variables. I cut all the unused stuff from your start script. You need to understand how strings work. The following... Local $hDownload = InetGet("ftp://user:password@ftp_site/name_of_file_to_recover_in_ftp_site", @DesktopDir & "\name_of_file_recupered_in_ftp_site", 1, 1) ... doesn't capture the values from your variables automatically - you must put the string together as below. See if you understand what is happening in the script below, and take it from there. ;Variables ;ftp_site Global $server = 'ftp_site' ;fisrt user Global $usernamenan = 'user1' ;password for the first user Global $passwordnan = 'password1' ;file to recover in ftp site Global $source = '/name_of_file_to_recover_in_ftp_site.zip' ; Size of the file in ftp site Local $nSize = InetGetSize("ftp://" & $usernamenan & ":" & $passwordnan & "@" & $server & $source) MsgBox(0, "Taille du fichier en Octets:", $nSize) ; To download the file Local $hDownload = InetGet("ftp://" & $usernamenan & ":" & $passwordnan & "@" & $server & $source, @DesktopDir & "\name_of_file_recupered_in_ftp_site.zip", 0, 0)
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