Source file is moving to remote server directory, but content of the file is not exactly the same
Hi All,
I am new to the WinSCP batch script. I have the below script to transfer the file to the remote server directory. My scope is to transfer the file to the remote server directory and copy the file to the archive folder on the same server. The current script is helping to move the file to the remote server directory, but the content of the transferred file coming with the below script. The exact content of the file is "sample test," but its appearing as below.
Also, the file is not copying to the archive folder on the same server. Please help with this. I really appreciate any help you can provide.
File content appearing as below in remote server:
This is the script
I am new to the WinSCP batch script. I have the below script to transfer the file to the remote server directory. My scope is to transfer the file to the remote server directory and copy the file to the archive folder on the same server. The current script is helping to move the file to the remote server directory, but the content of the transferred file coming with the below script. The exact content of the file is "sample test," but its appearing as below.
Also, the file is not copying to the archive folder on the same server. Please help with this. I really appreciate any help you can provide.
File content appearing as below in remote server:
ECHO cd "/agency1/office1/hr1/out/" >> %SCRIPTFILE% ECHO lcd "%SFTP_HOME%scripts\agency\office\hr\out\"" >> %SCRIPTFILE% ECHO put -delete "%SFTP_HOME%scripts\agency\office\hr\out\*.txt" >> %SCRIPTFILE%
@echo off ::: Begin set date for /f "tokens=1-4 delims=/-. " %%i in ('date /t') do (call :set_date %%i %%j %%k %%l) goto :end_set_date :set_date if "%1:~0,1%" gtr "9" shift for /f "skip=1 tokens=2-4 delims=(-)" %%m in ('echo,^|date') do (set %%m=%1&set %%n=%2&set %%o=%3) goto :eof :end_set_date ::: End set date SET CUR_HH=%time:~0,2% if %CUR_HH% lss 10 (set CUR_HH=0%time:~1,1%) SET CUR_NN=%time:~3,2% SET CUR_SS=%time:~6,2% SET CUR_MS=%time:~9,2% SET SFTP_HOME=E:\sftp\ SET SCRIPTFILE=%SFTP_HOME%\scripts\agency\office\hr\out\sample.txt SET LOGFILENAME=%SFTP_HOME%scripts\agency\SFTPLogs\hr\sample-out_%yy%%mm%%dd%.log ECHO SFTP_HOME=%SFTP_HOME% ECHO SCRIPTFILE=%SCRIPTFILE% ECHO LOGFILENAME=%LOGFILENAME% ECHO Copy File to Archive Folder COPY %SFTP_HOME%\scripts\agency\office\hr\out\*.txt "E:\sftp\agency\archive\hr\out\" ECHO Write WinSCP Script File ECHO option confirm off >> %SCRIPTFILE% ECHO option batch continue >> %SCRIPTFILE% ECHO cd "/agency1/office1/hr1/out/" >> %SCRIPTFILE% ECHO lcd "%SFTP_HOME%scripts\agency\office\hr\out\"" >> %SCRIPTFILE% ECHO put -delete "%SFTP_HOME%scripts\agency\office\hr\out\*.txt" >> %SCRIPTFILE% ECHO Start to push files to IT using WinSCP "C:\Program Files (x86)\WinSCP\WinSCP.exe" agency@dc.com /privatekey="E:\key\agency.ppk" /hostkey="*" /script=%SCRIPTFILE% /log=%LOGFILENAME% ECHO End to push files from App to IT using WinSCP DEL %SCRIPTFILE%