Topic "Calling WinSCP.bat file from SQL Stored Proc"

Author Message
SLING

Guest


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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Please read FAQ:
https://winscp.net/eng/docs/faq_scheduler
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License