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
WinSCPoffers scripting interface, see Automate file transfers (or synchronization) to FTP server or SFTP server.%year%. additionally, we have no idea if, at the time of running, the network location is available to the end user, perhaps usingPushD "\\pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test"would be a more sensible option. Additionally, you statefilelocation, but yourcopycommand will be copyingall filesin the top level of a directory namedTest; can you please clarify the task..Testto remote server which ismebillsin this location/cygdrive/d/VB_SHARE/astroQA/AFP/inTestdirectory? Did you try usingPushD, as advised? Is the code being run on exactly the same PC with the same user settings?PushD. It seem like the script unable to locate the destination/cygdrive/d/VB_SHARE/astroQA/AFP/in. end user have permissions to bothpbilandmebills. and using the same settings.