我尝试使用winSCP .bat脚本将SFTP文件发送到远程服务器,但是脚本保留提示“系统找不到指定的路径”。然后winscp将在其他位置打开新的会话标签。
文件位置:\ pbilsr01 \ ACCESS BILLING \%year%\ BMD Bill QA \ Jun \ Test
文件目标:/ 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
答案 0 :(得分:1)
将:Eftipi内容替换为
:Eftipi
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/command ^
"open sftp://mebills:password@astrobill.com.my/ -hostkey=""ecdsa-sha2-*****=""" ^
"put ""\\pbilsr01\ACCESS BILLING\%year%\BMD Bill QA\Jun\Test"" "/cygdrive/d/VB_SHARE/astroQA/AFP/in" " ^
"exit"