Akshay07 Posted December 21, 2009 Share Posted December 21, 2009 Hello all, I am using a .bat file to automize a FTP transfer. I know there is another way to do it using Inetget, but I do need to do the FTP transfer via command prompt. The batch file consist of this: ftp -s:ftp.txt It points to a text file that contains this: open <ftp IP address> <username> <password> get <file to download> When I run the .bat file manually, it works great. When I call it wih Autoit using Run ("ftp.bat") I see the command prompt window being opened and then the first line sent ("open <ftp IP address>") but this happens very quickly and the command prompt window is closed almost immediately (and of course, there is not ftp transfer starting). Any idea why? Thanks Link to comment Share on other sites More sharing options...
Fire Posted December 21, 2009 Share Posted December 21, 2009 Hi, Try RunWait() for this reason. [size="5"] [/size] Link to comment Share on other sites More sharing options...
Akshay07 Posted December 21, 2009 Author Share Posted December 21, 2009 Thanks for the quick answer, unfortunately, it does not help I see the same problem Link to comment Share on other sites More sharing options...
Mobius Posted December 21, 2009 Share Posted December 21, 2009 (edited) ftp -s:ftp.txt PAUSEThis is not a fix but if you put a pause cmd in your batch what error message (if any) does ftp.exe print to the command interface?I have a feeling the batch cannot find the file ftp.txt.orRunWait(@COMSPEC &" /c your.bat > FTP.log",@SCRIPTDIR)orRunWait(@COMSPEC &" /k your.bat",@SCRIPTDIR)You really don't need the batch you know, you could call ftp.exe directly with run().$OUT = "" $PID = Run("ftp.exe -s:"& @SCRIPTDIR &"\ftp.txt",@SCRIPTDIR,@SW_HIDE,7) IF $PID THEN WHILE 1 $OUT &= StdoutRead($PID) IF @ERROR THEN EXITLOOP WEND ELSE $OUT = "Failed to execute program." ENDIF MsgBox(64,@SCRIPTNAME,$OUT)Last bit untestedah, You need to display the ascii progress bar, that is a piece of information that may have helped. Edited December 21, 2009 by Mobius Link to comment Share on other sites More sharing options...
Akshay07 Posted December 21, 2009 Author Share Posted December 21, 2009 I already tried to pause 30 seconds after the RUN instruction but it is the same. I do need the command prompt, I need to see the progress in it (in the text file, there is a hash instruction missing), and not in any other progress bar. I don't know if it makes any difference, but I try to run the .bat file in a specific folder: Run ("C:\ftp\ftp.bat") And when I pause the script and copy/paste the Run command I use in the script into Window key/run, it works fine Link to comment Share on other sites More sharing options...
Fire Posted December 21, 2009 Share Posted December 21, 2009 For example: This is work for me: RunWait("cmd.exe /c echo anonymous>>c:\pass.gif") ;login RunWait("cmd.exe /c echo anonymous>>c:\pass.gif") ;pass RunWait("cmd.exe /c echo cd public >>c:\pass.gif") ;cd public RunWait("cmd.exe /c echo ls -lia>>c:\pass.gif") ;listing RunWait("cmd.exe /c ftp -v -s:c:\\pass.gif 212.38.114.20") ;connecting to ftp host after connection: Пользователь (212.38.114.20:(none)): ftp> cd public public: No such file or directory. ftp> ls -lia total 12 2 dr-xr-xr-x 6 0 5 512 May 8 2007 . 2 dr-xr-xr-x 6 0 5 512 May 8 2007 .. 716800 dr-xr-xr-x 2 0 5 512 Jun 27 2003 bin 940800 d--------- 2 0 5 512 Jun 27 2003 etc 492800 drwxr-xr-x 11 0 0 512 Jun 13 2009 incoming 336000 drwxr-xr-x 27 1004 0 1024 Nov 23 13:26 pub ftp> [size="5"] [/size] Link to comment Share on other sites More sharing options...
Akshay07 Posted December 21, 2009 Author Share Posted December 21, 2009 (edited) Hummm, your last answer is beyond my knowledge I tried this script from you (thanks a lot for it) and change one parameter to maximize the window $OUT = "" $PID = RunWait("ftp.exe -s:"& @SCRIPTDIR &"\Start_100MB_DL.txt",@SCRIPTDIR,@SW_MAXIMIZE,7) IF $PID THEN WHILE 1 $OUT &= StdoutRead($PID) IF @ERROR THEN EXITLOOP WEND ELSE $OUT = "Failed to execute program." ENDIF MsgBox(64,@SCRIPTNAME,$OUT) That looks very good, I am getting closer, but I have two more questions. 1/ Can I see the progress using "#" symbols? I really need to have this visible 2/ Will that piece of script allow the global script to keep on running without waiting the download to be completed? I forgot one important piece of information in my first message, I need to start the download AND proceed without waiting for the download to be completed Thanks! Edited December 21, 2009 by Akshay07 Link to comment Share on other sites More sharing options...
Mobius Posted December 21, 2009 Share Posted December 21, 2009 (edited) 4get about that code I posted, If you need to see the output in real time then reading the stdout buffer is not going to help you...(plus there is a stupid error in it where RunWait should be Run, because the above will not work with Runwait. *Doh*)Run(@comspec &' /k ftp.exe -s:"'& @SCRIPTDIR &'\Start_100MB_DL.txt"',@SCRIPTDIR,@SW_MAXIMIZE)orRun(@comspec &' /c ftp.exe -s:"'& @SCRIPTDIR &'\Start_100MB_DL.txt" && PAUSE',@SCRIPTDIR,@SW_MAXIMIZE)Of course, all this would not be necessary if you created a cui executable out of your script with Aut2Exe or physically modified the subsystem of AutoIt3.exe, because ftp.exe's output would automatically go to your exe's stdout window (or an existing cmd shell when executed from one). Edited December 22, 2009 by Mobius Link to comment Share on other sites More sharing options...
Akshay07 Posted December 22, 2009 Author Share Posted December 22, 2009 Thanks a lot for your time and your help, this is perfect!!! 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