we need to transfer files from one server to another server via SFTP.(Job scheduler)
Currently transfer is happening via FTP. Below is the script we are using to transfer fies.
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
set datestr=%d:~6,4%%d:~0,2%%d:~3,2%
rem IF %time:~0,1% GEQ 1 ( set timestr=%time:~0,2%%time:~3,2% ) else ( set timestr=0%time:~1,1%%time:~3,2% )
set timestr=0%time:~1,1%%time:~3,2%
echo %datestr%_%timestr%
echo open ac8b16-a13.no.eri.us >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo user username password >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo put \\MG2PLK\OutPut\MA-Operation\Extraction\WDESymphony.txt /dstage/dsdata/External_Input_Files/sympttkt/WDESymphony_%datestr%%timestr%.txt >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo put \\MG2PLK\OutPut\MA-Operation\Extraction\sympday-modified.txt /dstage/dsdata/External_Input_Files/sympttkt/sympday-modified_%datestr%%timestr%.txt >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo ! copy /Y \\MG2PLK\OutPut\MA-Operation\Extraction\WDESymphony.txt \\MG2PLK\OutPut\MA-Operation\WDESymphony.txt >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo ! copy /Y \\MG2PLK\OutPut\MA-Operation\Extraction\sympday-modified.txt \\MG2PLK\OutPut\MA-Operation\sympday-modified.txt >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo close >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
echo bye >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.txt
Date /T >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.log
Time /T >> \\MG2PLK\INPUTPATH\Excel\Important\WDESYMPHONY.log
C:\winnt\system32\ftp.exe -n -s:WDESYMPHONY.txt >> WDESYMPHONY.log
installed Winscp, and genarated public key , and share it to the another server team based on google search. and they have added public key to the exception list .
facing trouble to generate schedule script , could you please help me how to change this FTP to SFTP for transfering files. Thank you in advance.
Tried approach:
echo open sftp://ftp_user:password@ftp.MyFTPSite.com -hostkey="1234" >> ftpcmd.dat
echo put c:\directory\%1-export-%date%.csv >> ftpcmd.dat
echo exit >> ftpcmd.dat
winscp.com /script=ftpcmd.dat
del ftpcmd.dat
tried with above approach, but facing issue with syntax. there is no password
struggling with syntax for password