Page 1 of 1

Batch for remote ftp dowlaods

Posted: 15 May 2009 13:07
by t4mack
What up, I'm new to writing batch jobs in fact i really don't know anything about the other than saving them as .bat.

Well, on to the matter at hand. I need to know how to create a batch file for ftp downloads from a hosting domain. Anyone have any ideas thanks.

Posted: 16 May 2009 19:43
by Batcher

Code: Select all

@echo off
rem Your FTP username
set ftpUser=USERNAME
rem Your FTP password
set ftpPass=PASSWORD
rem Your FTP server IP
set ftpIP=192.168.0.2

set ftpFile=%temp%\TempAcc.txt
>"%ftpFile%" echo.%ftpUser%
>>"%ftpFile%" echo.%ftpPass%
>>"%ftpFile%" echo bin
>>"%ftpFile%" echo mget *.*
>>"%ftpFile%" echo bye
start ftp -v -i -s:"%ftpFile%" %ftpIP%

Posted: 18 May 2009 07:47
by t4mack
Thanks Batcher this really works. If you want I know a website where you can download testing material for certifications just let me know and i'll post it.

Posted: 17 Jun 2009 20:30
by k3lvinmitnick.co.cc
Batcher wrote:

Code: Select all

@echo off
rem Your FTP username
set ftpUser=USERNAME
rem Your FTP password
set ftpPass=PASSWORD
rem Your FTP server IP
set ftpIP=192.168.0.2

set ftpFile=%temp%\TempAcc.txt
>"%ftpFile%" echo.%ftpUser%
>>"%ftpFile%" echo.%ftpPass%
>>"%ftpFile%" echo bin
>>"%ftpFile%" echo mget *.*
>>"%ftpFile%" echo bye
start ftp -v -i -s:"%ftpFile%" %ftpIP%


Tks very much,
But, I wanna Send 1 file (Not MGET *.*) each day at one time. How can I ?

(If date=12 then send c:\12.abc
Loop it for all days in month)

Posted: 18 Jun 2009 07:40
by RElliott63

Code: Select all

Set "ftpFile=Script.ftp"
Set "Day=%Date:~3,2%"       REM Get Day of Month

Echo UserID    > %ftpFile%
Echo Password >> %ftpFile%
Echo bin      >> %ftpFile%
Echo lcd      >> %ftpFile%
Echo cd       >> %ftpFile%
Echo Put %Day%.abc  >> %ftpFile%
Echo bye     >> %ftpFile%

start ftp -v -i -s:"%ftpFile%" %ftpIP%

Posted: 18 Jun 2009 22:06
by ghostmachine4
if you can have gawk for win32

Code: Select all

BEGIN{
     ftpfile="Script.ftp"
     ftpip = "xx.xx.xx.xx"
     day = strftime("%d",systime())
     print "UserID" > ftpfile
     print "Password" > ftpfile
     print "bin" > ftpfile
     print "lcd" > ftpfile
     print "cd somewhere" > ftpfile
     print "put "day".abc" > ftpfile
     print "bye" > ftpfile
     cmd="ftp -v -i -s:"ftpfile" "ftpip
     print cmd
     system(cmd)
         system("del "ftpfile)
}


save the above as myscript.awk and on command line

Code: Select all

c:\workspace\>  gawk -f myscript.awk

Posted: 18 Jun 2009 22:07
by ghostmachine4
RElliott63 wrote:

Code: Select all

...
Set "Day=%Date:~3,2%"       REM Get Day of Month
....

getting day like this is dependent on regional settings. make it independent of it.

Posted: 23 Jun 2009 21:00
by k3lvinmitnick.co.cc
WOW ! TKs 2 all,

But, I mean: My file is abDDMMYY.xyz

How can I ?