0

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

Nalo Nenu
  • 29
  • 4
  • 1
    Or [How to convert Windows FTP script to WinSCP?](https://stackoverflow.com/q/20531986/850848) or [Replace Windows command FTP -s:E:\FtpScript.txt with SFTP?](https://stackoverflow.com/q/21102193/850848) or [Replace FTP with SFTP](https://stackoverflow.com/q/25311405/850848) and many many others - This is not a code writing service - Do your research and ask a specific question with a specific problem. – Martin Prikryl Feb 12 '18 at 17:53
  • *"facing issue with syntax. there is no password"* is pretty vague. There **is** a password in your script. So what's the **"issue"**? – Martin Prikryl Feb 12 '18 at 19:07
  • You didn't respond to my comments to this question, yet you are asking a [new question](https://stackoverflow.com/q/48777459/850848) already. – Martin Prikryl Feb 14 '18 at 06:54

0 Answers0