xesymusic Posted February 8, 2010 Share Posted February 8, 2010 Hey there, I am very new to scripting for AutoIt. I know a decent bit of PHP and C++, so my background isn't completely worthless. I am going to post my code now. My goal is to download files from my server to my local computer so I can further process the files. The problem right now is that the code does not wait for the terminal window to finish downloading the files. Any tips, or example code would be much appreciated. I've browsed around the site and most of the code is way more complex than my simple needs at the moment. Run("cmd"); Sleep(2000); Send("ftp{ENTER}"); WinWaitActive("C:\WINDOWS\system32\cmd.exe - ftp"); Send("open HOSTNAME{ENTER}"); Sleep(3000); Send("USERNAME{ENTER}"); Sleep(3000); Send("PASSWORD{ENTER}"); Sleep(3000); Send("cd directory/structure/{ENTER}"); Send("prompt{ENTER}"); Send("mget images/{ENTER}"); Send("bye{ENTER}"); Sleep(10000); Send("move /Y *.jpg C:\WHERE\its\downloaded\to{ENTER}"); Sleep(10000); Send("exit{ENTER}"); WinActivate("Window Title"); Sleep(3000); MouseMove(499, 64); Sleep(2000); MouseClick(""); Any ideas on how to revamp this code to pause until my ftp finished transferring all of the files? Any leads for tutorials for a noob would be greatly appreciated. Thanks in advance for any help. Best, Doughty Link to comment Share on other sites More sharing options...
Steveiwonder Posted February 9, 2010 Share Posted February 9, 2010 (edited) If you ask me, use WiseFTP Alot easier... atleast i do for my web servers Edited February 9, 2010 by Steveiwonder They call me MrRegExpMan Link to comment Share on other sites More sharing options...
enaiman Posted February 9, 2010 Share Posted February 9, 2010 Do a search for StdoutRead and StdinWrite; using them you can work out a command-response system (send a command and expect a certain response - the prompt - or an error message). There should be several examples around. In the actual form - you have no error control; whatever the server sends back (accept, deny connection ...,) you are waiting 3 seconds and send the user name anyway then regardless of the answer, you send the password.... DO a little bit of search and I'm sure you'll find something. Good luck, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
singbass Posted February 25, 2010 Share Posted February 25, 2010 I use the following for most all of my simple ftp processes. The downside is that there is no way to trap any error codes so I can't monitor for success or failure. $ftpfile = "ftpfile.ftp" ;name of file that will be used for ftp responses $ftpfilename = FileOpen($ftpfile, 2) ;open the ftp file with write access, overwriting previous versions FileWriteLine($ftpfilename, "open 100.200.300.400") FileWriteLine($ftpfilename, "username") FileWriteLine($ftpfilename, "password") FileWriteLine($ftpfilename, "prompt") FileWriteLine($ftpfilename, "mget \\servername\sharename\filename*.* /foldername/*.*") FileWriteLine($ftpfilename, "bye") FileClose($ftpfilename) ;close the ftp response file RunWait(@ComSpec & " /c " & 'ftp -s:"' & $ftpfile & "", "", @SW_MINIMIZE) ;executes the ftp command using the contents of $ftpfile as responses to the prompts. FileDelete($ftpfile) ;delete the ftp response file since it is no longer needed Link to comment Share on other sites More sharing options...
jvanegmond Posted February 25, 2010 Share Posted February 25, 2010 FTP UDF: http://www.autoitscript.com/forum/index.php?showtopic=78378 github.com/jvanegmond 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