Topic "How to execute Winscp from SQL Server 2000 xp_cmdshell?"

Author Message
Rey94133

Guest


WinSCP sessions can be stored when run from its UI or command prompt.
However, it fails when executed from query analyzer due to the fact that it can find or remember any stored sessions. Ex T-SQL script:

declare @cmd varchar(1000)
set @cmd = 'CMD /C ""c:\program files\winscp\winscp.com" /script="D:\GEMS_EXPORT\BVHE\ftp_command.txt""'
exec master..xp_cmdshell @cmd

Results:
batch on
confirm off
No session.
Searching for host...
Connecting to host...
Authenticating...
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 cd:7a:01:2b:5b:19:cc:97:8b:65:c5:c4:f0:6d:72:f6
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?
(Y)es, (N)o, (C)ancel: Cancel
Host key wasn't verified!
Authentication failed.
transfer binary
No session.
D:\GEMS_EXPORT\BVHE
No session.
No session.
NULL

As you can see, I cannot answer for the prompt of adding the host key to the cache since it is executed via xp_cmdshell. Do you know of some workaround?
Advertisements
Rey94133

Guest


I think the solution to my problem is using the new feature "/hostkey" which is still pending. Any idea, when the next release would be?
Rey94133

Guest


It's funny that I have been replying to my own post Laughing

Anyhow, the solution is to configure the storage options (e.g. ini instead of registry). The system would then reference the ini file and remember the host key. Thus, resolves the xp_cmdshell issue. Hope this helps the needy Mr. Green
andy0789

Guest


Thanks for the tip! Switching it to store all settings in an ini file rather than in the registry worked great!
Arun

Guest


andy0789 wrote:
Thanks for the tip! Switching it to store all settings in an ini file rather than in the registry worked great!



can u explain indetail to store in ini file, becoz i have face the same issue. still not solved
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Arun wrote:
can u explain indetail to store in ini file, becoz i have face the same issue. still not solved

Please read documentation. If that does not help, come back.
_________________
Martin Prikryl
Guest




Hi
We execute the below line from command prompt
>E:\winscp382.exe /console /script=E:\FtpGetFile.txt


The FtpGetFile.txt contain below script
option batch on
option confirm off
open username:password@xx.xxx.com
get Upload.txt e:\Upload.txt
close
exit



it throws authentication failure error
hostkey etc...
can u explain where to put hostkey value
or using ini file?javascript:emoticon('Embarassed')
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Quote:
can u explain where to put hostkey value
or using ini file?

Please read FAQ. If that does not help, come back.
_________________
Martin Prikryl
halx

Guest


the first time you run it, use ' echo Y | {....your command....} ' this will hit "Y"


Twisted Evil
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
halx wrote:
the first time you run it, use ' echo Y | {....your command....} ' this will hit "Y"

That's indeed the worst solution.
_________________
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