Topic "using vbs to connect sftp and use "put" command"

Author Message
FrankT
[View user's profile]

Joined: 2011-12-02
Posts: 3
Hi! I am new to to scripting and WinSCP. I need to create a script to connect to a ftp service and copy files to it. I've tied the following with no success. Please help!!!

Dim wshShell
Dim sftpcmd
Set wshShell = WScript.CreateObject("WScript.Shell")


sftpcmd = "winscp /console /command " & """open sftp://nstcn61:password@10.10.1.100 -hostkey= ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX" & "put c:\sysaudit\*.*" & "close""" & " " & """exit"

wshShell.Run(sftpcmd),1,true

wscript.sleep(20000) 'wait for 20 seconds until sftp is done




Any help would be appreciated.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24538
Location: Prague, Czechia
You have quotes all wrong. I do not know VBS, but I guess right format is:
sftpcmd = "winscp /console /command ""open sftp://nstcn61:password@10.10.1.100 -hostkey=""""ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX"""""" ""put c:\sysaudit\*.*"" ""close"" ""exit"""

Read also:
http://winscp.net/eng/docs/commandline#syntax

Of course the XX:XX:XX... has to be replaces with actual fingerprint.
FrankT
[View user's profile]

Joined: 2011-12-02
Posts: 3
prikryl wrote:
You have quotes all wrong. I do not know VBS, but I guess right format is:
sftpcmd = "winscp /console /command ""open sftp://nstcn61:password@10.10.1.100 -hostkey=""""ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX"""""" ""put c:\sysaudit\*.*"" ""close"" ""exit"""

Read also:
http://winscp.net/eng/docs/commandline#syntax

Of course the XX:XX:XX... has to be replaces with actual fingerprint.




WOW!!! I love you, man!!! You just fixed a problem for me that has been a thorn in my side for days!!! Thank you, thank you, thank you!!!
FrankT
[View user's profile]

Joined: 2011-12-02
Posts: 3
OK, I have one last problem with this script; In the console, I am getting the following msg.

"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......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(a)ncel, (C)opy Key:
"

I need it to pass on the key automatically. Any insite on how to do this with the example you provided?

Thanks!!!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24538
Location: Prague, Czechia
Please read documentation:
http://winscp.net/eng/docs/scripting#hostkey
_________________
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