Calling WinSCP.bat file from SQL Stored Proc

Advertisement

SLING
Guest

Calling WinSCP.bat file from SQL Stored Proc

Hello

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 "mysite@ecc.xxx.xxx.com"
Connecting to 99.99.99.99 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"
/log="C:\operations\tck\log.log"
/console
/command "option batch on" "option confirm off"
"open mysite@ecc.xxx.xxx.com" --this is my stored session that works perfectly
"cd /in"
"put %1" --this is a parameter (file name) passed to my batch file
"close"
"exit"
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

Advertisement

Advertisement

You can post new topics in this forum