0

I am trying to create a script which copies the contents of one directory to an FTP location but every example I have tried to work with has failed. I need this to target a folder within the FTP site can anyone point me in the right direction.

Thank you

Batch file is below.

@ftp -i -s:"%~f0"&GOTO:EOF
open 0.0.0.0
name@address.com
Pa55word
!:--- FTP commands below here ---
lcd c:\program files\system\location
cd  storage
binary
mput "*.*"
disconnect
bye

1 Answers1

0

Once FTP is open you are no longer at a command prompt. You are inside FTP. You need to use your batch file to write the ftp script,FTPInstructions.ftp in the following example. Then open ftp, telling it to run the script.

When you invoke the ftp.exe program to run the ftp script from the batch file you can redirect the ftp.exe console output to a log file and examine that log file for errors. You'll need to redirect both stdout and stderr. Something like this:

echo open 0.0.0.0>FTPInstructions.ftp
echo user UserName>>FTPInstructions.ftp
echo Password>>FTPInstructions.ftp

echo something>>FTPInstructions.ftp
echo something else>>FTPInstructions.ftp
.
.
echo bye>>FTPInstructions.ftp

ftp.exe -n -s:FTPInstructions.ftp>FTPSession.log 2>&1

You can then use FIND or FINDSTR in the batch file to locate any error messages output by ftp.exe in the FTPSession.log file.

thx1138v2
  • 566
  • 3
  • 6