HI Folks -
I have a server I need to transfer files to that requires authentication to log on. What is the best way to achieve this using FTP from batch? I have the password file.
Thanks!
FTP and password file?
Moderator: DosItHelp
Re: FTP and password file?
The FTP command builtin to Windows can be scripted with a script file.
You can put all your commands in this file that you need to run the FTP. That includes, the server you want to connect to, username, password, files you want to upload or download, etc, etc ,etc
http://ss64.com/nt/ftp.html
Code: Select all
FTP -s:GetFiles.txt
You can put all your commands in this file that you need to run the FTP. That includes, the server you want to connect to, username, password, files you want to upload or download, etc, etc ,etc
http://ss64.com/nt/ftp.html
Re: FTP and password file?
Hi Squash -
Ah yes, that's what I currently use:
However, I need to authenticate with a private key when logging in using a *.ppk file i have. Will that work? Perhaps Winscp would be a better option in this situation?
Ah yes, that's what I currently use:
Code: Select all
::-- Generate FTP Commands File --::
ECHO open %1>%8
ECHO %2>>%8
ECHO %3>>%8
ECHO lcd /D "%4">>%8
ECHO cd "%5">>%8
ECHO binary>>%8
ECHO hash>>%8
ECHO %6 "%7">>%8
ECHO quit>>%8
::-- Launch FTP and Pass Script to it --::
FTP.exe -v -i -s:%8
::-- Delete FTP Commands File on Exit --::
DEL %8
EXIT /B
However, I need to authenticate with a private key when logging in using a *.ppk file i have. Will that work? Perhaps Winscp would be a better option in this situation?
Re: FTP and password file?
FTP is FTP. It is not SFTP. If you need to use a key file then you are using SSH, in which case you will need to use a 3rd party utility. It is my understanding that PSFTP and WINSCP can be scripted.
Re: FTP and password file?
Hi Squash -
I thought so. I needed to leverage WinSCP to do so:
Thanks, Squash!
I thought so. I needed to leverage WinSCP to do so:
Code: Select all
:File_Transfer
echo ********************************************************>>%logfile%
echo Transfer file to Linux >>%logfile%
echo ********************************************************>>%logfile%
::-- Set Variables for WSCP Process --::
SET WSCP_SRVR=00.11.222.33
SET WSCP_USER=mdm
SET WSCP_PSWD=%MAINPATH%Scripts\NTScripts\ENTYVIO\INFA_DEV_MDM.ppk
SET WSCP_LD=%MAINPATH%%FILEPATH%%EXPORTPATH%
SET WSCP_RD=/home/mdm/s3mdm/
SET WSCP_ITEM=EVIO_Activities.csv
SET WSCP_CMD_FILE=%~n0.tmp
::-- Variables are passed to executable script in a specific order --::
CALL :EXEC_WSCP %WSCP_USER% %WSCP_SRVR% %WSCP_CMD_FILE% %WSCP_PSWD% %WSCP_LD% %WSCP_ITEM% %WSCP_RD%
GOTO S1
:EXEC_WSCP
::-- Generate WinSCP Commands File --::
ECHO open %1@%2>%3
ECHO put %5%6 %7>>%3
ECHO exit>>%3
::-- Launch WinSCP and pass script to it --::
"%WINSCP_PATH%winSCP.exe" /script=%3 /privatekey=%4
::-- Delete WinSCP Commands File when process completes --::
DEL %3
GOTO :EOF
Thanks, Squash!