Discussion Locked

A batch file with FTP site

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to write a batch file which can do;
1.FTP to a site.
2.Downloan a file to local machine.
3.In FTP site, rename the file download to *.old
4.close the connection.

I am stuck on #2. I want to send "mget" command and send "y" after that. How can do this?

Sunny

6 replies

by lintadsl

Thanks for the link but the man page looks like dealing with Unix/Linux server. I am dealing with MS windows servers. I don't think I can kick .netrc file on windows system.

by joseph moore

Actually, you can use a log file with FTP that contains all commands you want to perform. I do this myself. You then run the FTP command with the -s switch to have FTP run with using the log file.

For example, here is my TXT file of FTP commands.I call this file UPLOAD.TXT

open FTP.SITE.COM
LOGINNAME
PASSWORD
lcd C:/TEMP
put FILE1.TXT DIR1/AFILE.TXT (replace
put FILE1.TXT DIR2/BFILE.TXT (replace
quit

So, in my C:\TEMP folder are 2 files, FILE1.TXT and FILE2.TXT. I upload these files onto the FTP server, replacing AFILE.TXT and BFILE.TXT with my copies.

Now, in your BAT file, have it say this:

ftp -s:C:\TEMP\UPLOAD.TXT

That will kick off the FTP session and it will run everything in UPLOAD.txt

So, just makeyour own TXT file, put in everything you want to do, then have the BAT file run FTP with the -s switch.

hope this helps

by lintadsl

Thank you very much. This is the what I expected to see. I added -i option and I could be able to run MGET and MDEL command. So, I use ftp -i -s:upload.txt
Again, thank you!
Lint

This discussion is closed to new replies.