Reputation: 85
I try to SFTP file to remote server using winSCP .bat script but the script keep prompt "The system cannot find the path specified." And winscp will open new session tab to other location.
File location : \pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test
File destination : /cygdrive/d/VB_SHARE/astroQA/AFP/in
@echo off
echo %date%
set month=%date:~0,2%
echo month=%date:~0,2%
set day=%date:~3,2%
echo day=%date:~3,2%
set year=%date:~6,4%
echo year=%date:~6,4%
set LookForFile="\\pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test\*.*"
:CheckForFile
IF EXIST %LookForFile% GOTO Eftipi
echo %time% : The file is not ready yet. Wait 5seconds
TIMEOUT /T 5 >nul
GOTO CheckForFile
:Eftipi
echo.
echo start SFTP
echo Transfering QA file from 'Pbil' folder to QA serve location:(cygdrive/d/VB_SHARE/astroQA/AFP/in)
echo Start time : %date% %time%
"C:\Program Files (x86)\WinSCP\WinSCP.exe" sftp://mebills:pass****@astrobill.com.my/ -hostkey="ecdsa-sha2********"
copy "\\pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test" "/cygdrive/d/VB_SHARE/astroQA/AFP/in"
echo End time : %date% %time%
pause
Upvotes: 0
Views: 1108
Reputation: 85
Replace :Eftipi content to
:Eftipi
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/command ^
"open sftp://mebills:[email protected]/ -hostkey=""ecdsa-sha2-*****=""" ^
"put ""\\pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test"" "/cygdrive/d/VB_SHARE/astroQA/AFP/in" " ^
"exit"
Upvotes: 1