FTP commands in a batch script does not working pr

2020-02-13 06:08发布

问题:

I've made a simple FTP upload script that should upload multiple files from a Windows 2008 Server to the FTP location. I've tried this manually by executing every command of the script directly in CMD and it works fine. However when I run script.bat it says that none of the commands are recognized as internal or external commands. I checked the ENV variables and there is a path to System32 so it should be fine. Can anyone please help with this. Thank you

open xx.xxx.xx.xx
user
pass
prompt
bin
lcd X:\test\test\
cd /tempTest/tempTest
binary
mput "*.*"
disconnect
quit

回答1:

Place your script in a text file on your desktop called ftpscript.txt

Create a batch file called getftp.bat and inside it have this - then you can click the bat file.

@echo off
ftp -i -s:"%userprofile%\desktop\ftpscript.txt"
pause


回答2:

You can also try something like that with a batch file for multiple file Upload :

MultipleFileUpload.bat

@echo off
Title Multiple file Upload by Hackoo
mode con cols=85 lines=22 & Color A
::***********************************
Set FTPSERVER=ftp.xx.xxx.xx.xx.com
Set USER=UserName
Set Password=YourPassword
Set LocalFolder=X:\test\test
Set RemoteFolder=/tempTest/tempTest/
::***********************************
> ft.do echo Open %FTPSERVER%
>> ft.do echo %USER%
>> ft.do echo %Password%
>> ft.do echo prompt n
>> ft.do echo bin
>> ft.do echo lcd %LocalFolder%
>> ft.do echo cd %RemoteFolder%
>> ft.do echo mput *.*
>> ft.do echo bye
ftp -s:ft.do
del ft.do
Pause