Calling WinSCP.bat file from SQL Stored Proc



Calling WinSCP.bat file from SQL Stored Proc


I created a stored session using the WinSCP gui.
Then I created a dos batch file that opens my connection using the stored session.
My files gets uploaded and everything works perfectly.

Now I created a SQL Stored Procedure that will run on a schedule and will make
use of my WinSCP batch file to SFTP files to the client site.

I get the following message in my log when executing the batch file :

Looking up host ""
Connecting to port 22
Server version: SSH-2.0-SSHD
We believe remote version has SSH-2 ignore bug
Using SSH protocol version 2
We claim version: SSH-2.0-WinSCP_release_4.3.4
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Asking user:
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.

The server's rsa2 key fingerprint is:
ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx

If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.

Continue connecting and add host key to the cache? ()
Attempt to close connection due to fatal exception:
Host key wasn't verified!
Closing connection.
Sending special code: 12

But when I fire that exact same batch file - it works perfectly ?

Why on earth would my stored session work in the batch file - but not when that exact batch file is fired from SQL ?

I tried to add my hostkey to my batch file - but failed on syntax.

My working batch file currently :

@echo off
"C:\Program Files (x86)WinSCP\WinScp.exe"
/command "option batch on" "option confirm off"
"open" --this is my stored session that works perfectly
"cd /in"
"put %1" --this is a parameter (file name) passed to my batch file
echo %errorlevel% --I get my result here - usually a 0 when .bat is fired and a
--1 when fired from SQL.

Any ideas why this would be happening to me?

Thanks in advance.

Reply with quote



You can post new topics in this forum