It seems that the script will trigger an infinite loop, which causes the script to never stop. Try omitting the @echo off from your script to see this happening. Either try renaming your batch file, add an extension to the ftp command (ftp.exe) or even provide a full path to the executable to make it work.
Batch file to send a file to an FTP server
-
09-03-2022 - |
Question
I have a batch file (ftp.bat) that looks like:
@echo off
echo user etm124> ftpcmd.dat
echo testing123>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.DriveHQ.com
del ftpcmd.dat
This file is located in C:\
. Also located in that directory is a file called remote.txt
. When running this in the C:\
directory, it just hangs:
C:\>ftp.bat c:\remote.txt
If I look in the C:\
, I can see that the ftpcmd.dat
file has been created, but my script just hangs.
When I run this locally on my machine, I can send files just fine. But if I try to run this on one of my Windows Server 2003 machines, it hangs.
Anything I'm missing?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow