Batch for remote ftp dowlaods

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
t4mack
Posts: 4
Joined: 15 May 2009 12:55

Batch for remote ftp dowlaods

#1 Post by t4mack » 15 May 2009 13:07

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.

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

#2 Post by Batcher » 16 May 2009 19:43

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%

t4mack
Posts: 4
Joined: 15 May 2009 12:55

#3 Post by t4mack » 18 May 2009 07:47

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.

k3lvinmitnick.co.cc
Posts: 6
Joined: 17 Jun 2009 20:17
Location: http://vietdzung.net
Contact:

#4 Post by k3lvinmitnick.co.cc » 17 Jun 2009 20:30

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)

RElliott63
Expert
Posts: 80
Joined: 04 Feb 2009 10:03

#5 Post by RElliott63 » 18 Jun 2009 07:40

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%

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#6 Post by ghostmachine4 » 18 Jun 2009 22:06

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

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#7 Post by ghostmachine4 » 18 Jun 2009 22:07

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.

k3lvinmitnick.co.cc
Posts: 6
Joined: 17 Jun 2009 20:17
Location: http://vietdzung.net
Contact:

#8 Post by k3lvinmitnick.co.cc » 23 Jun 2009 21:00

WOW ! TKs 2 all,

But, I mean: My file is abDDMMYY.xyz

How can I ?

Post Reply