Using a batch script, I wanted to make a copies of files from a server to an FTP server and got username and password errors.
My batch file code is this:
<code>@echo off
:: Define FTP variables
set "ftpServer=ftp-test.scs.group.wan"
set "ftpUser=*********"
set "ftpPassword=*******"
set "localFolderPath=D:DOCSEDIoutbound"
set "remoteFolderPath=/invoice/in/"
:: Create FTP script commands
(
echo open %ftpServer%
echo user %ftpUser% %ftpPassword%
echo binary
echo lcd "%localFolderPath%"
echo cd "%remoteFolderPath%"
echo mput *.*
echo bye
) > ftpCommands.txt
:: Execute FTP script with verbose output for debugging
ftp -v -n -s:ftpCommands.txt
:: Check if FTP operation was successful
if %ERRORLEVEL% neq 0 (
echo ERROR: FTP upload failed.
del ftpCommands.txt
pause
exit /b %ERRORLEVEL%
)
:: Clean up temporary file
del ftpCommands.txt
@echo Files have been uploaded successfully!
pause
</code>
<code>@echo off
:: Define FTP variables
set "ftpServer=ftp-test.scs.group.wan"
set "ftpUser=*********"
set "ftpPassword=*******"
set "localFolderPath=D:DOCSEDIoutbound"
set "remoteFolderPath=/invoice/in/"
:: Create FTP script commands
(
echo open %ftpServer%
echo user %ftpUser% %ftpPassword%
echo binary
echo lcd "%localFolderPath%"
echo cd "%remoteFolderPath%"
echo mput *.*
echo bye
) > ftpCommands.txt
:: Execute FTP script with verbose output for debugging
ftp -v -n -s:ftpCommands.txt
:: Check if FTP operation was successful
if %ERRORLEVEL% neq 0 (
echo ERROR: FTP upload failed.
del ftpCommands.txt
pause
exit /b %ERRORLEVEL%
)
:: Clean up temporary file
del ftpCommands.txt
@echo Files have been uploaded successfully!
pause
</code>
@echo off
:: Define FTP variables
set "ftpServer=ftp-test.scs.group.wan"
set "ftpUser=*********"
set "ftpPassword=*******"
set "localFolderPath=D:DOCSEDIoutbound"
set "remoteFolderPath=/invoice/in/"
:: Create FTP script commands
(
echo open %ftpServer%
echo user %ftpUser% %ftpPassword%
echo binary
echo lcd "%localFolderPath%"
echo cd "%remoteFolderPath%"
echo mput *.*
echo bye
) > ftpCommands.txt
:: Execute FTP script with verbose output for debugging
ftp -v -n -s:ftpCommands.txt
:: Check if FTP operation was successful
if %ERRORLEVEL% neq 0 (
echo ERROR: FTP upload failed.
del ftpCommands.txt
pause
exit /b %ERRORLEVEL%
)
:: Clean up temporary file
del ftpCommands.txt
@echo Files have been uploaded successfully!
pause
I cannot connect with username and password.
10