wodSFTPdll - using VB Script (General questions)
Hi,
I'm trying to transfer a file (obviously!) from one server to another using the security provided by wodsftp.
The problem is I am trying to use VB Script - it's a new challenge.
Problem is (my VB Script knowledge is average and rusty) and I can't find any sample code that has used wodsFTP before - does anyone know of a good location or in fact have any sample code they have used before using VBS
Re: wodSFTPdll - using VB Script
Douglash,
here's simple VBS file that will connect to the server and give you listing of / directory. I put comments arround 'GetFile' call - you can call GetFile/PutFile to transfer files too, one after another, in the sequence.
[code]
Dim sftp
set Sftp = CreateObject( WeOnlyDo.wodSFTPCom.1 )
sftp.Blocking = 1
sftp.Hostname = your_hostname
sftp.Login = your_login
sftp.Password = your_password
sftp.Connect
' if you get an error, you can trap it here
'sftp.GetFile c: emp , /home/joe/somefile
sftp.ListDir /
wscript.echo sftp.ListItem
sftp.Disconnect[/code]
Hope I helped.
Kreso
Re: wodSFTPdll - using VB Script
Thanks, this is helpful.
We have just acquired the wodSFTP component and try to use it as well with VBS. However, I could not found a way to obtain back the various events of the component, such as Connected and Done. Is there any way to get all the event of wodSFTP with VBS?
Futhermore, your below below mentionned 'if you got an error, you can trap it here . Should the vbs ERR object be queried or should it be the ErrorText property of the wodSFTP object? Ìt seem clearer with the events of to do it.
An email response would certainly be appreciated (Admin: Look in my profile)
Regards,
Richard
Douglash,
[code]
Dim sftp
set Sftp = CreateObject( WeOnlyDo.wodSFTPCom.1 )
sftp.Blocking = 1
sftp.Hostname = your_hostname
sftp.Login = your_login
sftp.Password = your_password
sftp.Connect
' if you get an error, you can trap it here
'sftp.GetFile c: emp , /home/joe/somefile
sftp.ListDir /
wscript.echo sftp.ListItem
sftp.Disconnect[/code]Hope I helped.
Kreso
Re: wodSFTPdll - using VB Script
This isn't nice VBS what I suggest here, but I think it will work correctly for you. I took it from wodFtpDLX sample, just changed 'FtpDLX' to 'SFTP': [code]Option Explicit
Dim objFTP, lst
Set objFTP = WScript.CreateObject( WeOnlyDo.wodSFTPCom.1 , wod_ )
' please change these lines, from here
WScript.echo Please edit this file and setup Login, Hostname and Password properties
objFTP.Hostname = put.your.host
objFTP.Login = yourlogin
objFTP.Password = yourpass
' to here
objFTP.Blocking = 1
objFTP.Connect
objFTP.ListDir ( / )
lst = objFTP.ListItem
WScript.echo lst
objFTP.Disconnect
Sub wod_Connected(ErrorCode, ErrorText)
WScript.Echo Connected & ErrorText
End Sub
Sub wod_Disconnected()
WScript.Echo Disconnected
End Sub
[/code]
Re: wodSFTPdll - using VB Script
Thanks for the fast reply. I will have a look at it! It look like to be exactly what I was looking for.
Futhermore, I have another inquiry regarding the wodSFTP component. It seem like we experiencied some CRC failure while uploading to a SFTP server (with key encryption and password). Our programmer tried the follwoing code:
[code]
Keys.Load Keys path
If Err.Number = 0 Then
SFTP.Resume = True
SFTP.Blocking = True
SFTP.PrivateKey = Keys.PrivateKey(0)
SFTP.Authentication = 0
SFTP.Login = Login
SFTP.Password = PassW
SFTP.Connect & Site & , 22
If SFTP.State = 3 Then
SFTP.PutFile source, destination
If Err.Number = 0 Then
' transfert is a success
end if
SFTP.Disconnect
end if
end if
[/code]
Is the the appropriate way to test if the file was sended with success? Otherwise, which method is more appropriate?
Regards,
Richard
Re: wodSFTPdll - using VB Script
Not sure how you can get CRC errors. There can be *NO* errors during send. If there are, SSH layer would broke before file is uploaded.