Link to home
Start Free TrialLog in
Avatar of ben1211
ben1211Flag for Malaysia

asked on

Writing a FTP Batch File

I normally access FTP with a a batch file called FTP-Fri using the command:
%windir%\system32\ftp.exe  -n  -s:C:\FTP-FRI-MONTH-END.txt

This command reads from the text file C:\FTP-FRI-MONTH-END.txt

Assuming I didn't want to read from the text file and wanted the FTP to run directly from the batch file FTP-Fri.bat

Is this possible? If it is...how do I do this? What are the commands to put into the batch file?
Avatar of shoaibbhatti007
shoaibbhatti007
Flag of Pakistan image

I used WINBATCH tool, this is the best for batch processes
Avatar of Steve Knight
Well.  You can 'cheat' in anumber of ways.  These include:

batch file like this:

goto start
open xyz
username
password
cd /whatever
get xyz.txt
quit
:start
ftp yourhost -s thisbatchfile.bat

i.e. it uses the same file for both.  Bit messy.

Other way is to write a temporary text file, e.g.

@echo off
set file="%temp%\ftpfile.txt"
echo open yourserver> %file%
echo username>>%file%
echo password>>%file%
echo cd /whatever>>%file%
echo get yourfile.txt>>%file%
ftp yourhost -s %file%
del %file%

i.e. using > to create a file and >> to append each line to it.

Steve
Avatar of ben1211

ASKER

dragon-it.....i am sorry, but haven't an idea what you're talking about. Please explain.
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial