batch file - SQL Server agent for scheduling SFTP using WinSCP under SSIS -


i have batch script generates winscp upload script upload file sftp location. when run batch file via command prompt - runs , loads it. called same thru ssis execute process task - runs , loads it. when put same on sql agent - tried following 2 options:

  1. using operating system (cmdexec) - cmd.exe /c "\.bat"
  2. added ssis package ssisdb , added job step.

with both above options job showed successful run. file not uploaded! ideas on happening?

here's batch script:

echo off set winscp=c:\"program files (x86)"\winscp\winscp.com set stagingdirectory=\\<staging path>\ set scriptpath=\\<scriptpath>\uploadscript.txt set ftphost=xx.xx.xx.xx set ftpuser=user set ftppass=password set filename=test.xlsx set ftpflags= @rem ftpflags: -explicit  echo deleting uploadscript if exists  if exist %scriptpath% del /f %scriptpath% if exist %scriptpath% exit 1  echo generating winscp upload script  >>%scriptpath% echo option batch abort >>%scriptpath% echo option confirm off >>%scriptpath% echo open sftp://%ftpuser%:%ftppass%@%ftphost% %ftpflags% >>%scriptpath% echo option transfer binary >>%scriptpath% echo put %stagingdirectory%%filename% / >>%scriptpath% echo close >>%scriptpath% echo exit  echo launching winscp upload  start /wait %winscp% /console /script=%scriptpath% 

as start winscp via start (why?), exit code not propagated ssis. so, never learn, if script fails. , fails.

you should enable logging, can see what's wrong.

you should use code propagate winscp exit code ssis , enable logging:

%winscp% /log=\\<scriptpath>\uploadscript.log /script=%scriptpath% exit /b %errorlevel% 

(note winscp.com not have /console parameter)


anyway, 1 clear problem not specify expected ssh host key in script. when run script manually, have key cached in registry of windows account. under ssis different account used, , host key cache empty. should add -hostkey switch open command in script make script independent on cache. see where ssh host key fingerprint authorize server?

when testing script, add /ini=nul parameter isolate script configuration.


for , other hints, when debugging winscp running under ssis, see my script works fine when executed manually, fails or hangs when run windows scheduler, ssis or other automation service. doing wrong?

and finally, see winscp sftp task ssis.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -