tr1px Posted August 29, 2008 Share Posted August 29, 2008 (edited) Corrected a problem in the function readOut() !!! Now it works like it is suppose to.This script opens up a command prompt and establishes an FTP connection to a server then downloads the whole directory of files. Now in order to run other commands after the process is finished I needed to be able to get the output from the prompt so I copy and paste the text into a file in a loop and search for the line that tells me that it is finished which in this case would be ftp>. Now that I know it is done I can run other commands like delete the files of the server they are sitting on.Here is the code finally...expandcollapse popup#include <File.au3> Run("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send("cd c:\ftpdl") Send("{ENTER}") Send("ftp -i") Send("{ENTER}") Sleep(3000) Send("open ftpserver.net") Send("{ENTER}") Sleep(12000) Send("username") Send("{ENTER}") Sleep(4000) Send("password") Send("{ENTER}") Sleep(10000) Send("mget *.csv");start the download process Send("{ENTER}") $exitNum = 5 ;any number that will keep the loop going While $exitNum = 5 Send("!{SPACE}");this segment copies the output Send("e") Send("s") Send("!{SPACE}") Send("e") Send("y") $outPut = ClipGet();here we get the output from the clipboard writeOut($outPut) ;send the output to our function readOut() WEnd Send("Finished");here we can run more commands or close the prompt or do whatever Func writeOut($data) ; Write the data to a file $file = FileOpen("commanddata.dat", 2); FileWrite($file, $data) FileClose($file) EndFunc Func readOut() $file2 = FileOpen("commanddata.dat", 0) $lastline = _FileCountLines("commanddata.dat") $line = FileReadLine($file2, $lastline) $match = StringCompare($line, "ftp>");check if the download is complete - return 0 if it does If $match = 0 Then ;i had to correct this part $exitNum = 6 Return $exitNum Else $exitNum = 5 Return $exitNum EndIf EndFuncHope you guys find this useful. This is my first little program that I wrote in AutoIt. Edited August 29, 2008 by tr1px Link to comment Share on other sites More sharing options...
tr1px Posted August 29, 2008 Author Share Posted August 29, 2008 I had to make a correction to this script in the function readOut() $match = StringInStr($line, "ftp>") actually is wrong and has been changed to StringCompare($line, "ftp>") which returns a 0 if it matches. Sorry for the mistake. Link to comment Share on other sites More sharing options...
newbie100 Posted September 23, 2008 Share Posted September 23, 2008 thanks. this is what i've been looking for 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