Re: Data in file sent through SFTP are being trunc - WeOnlyDo Discussion board

Re: Data in file sent through SFTP are being trunc (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Tomek, Monday, May 11, 2009, 15:32 (5436 days ago)

I couldn't edit so below is my post in more clear form.

Hi,


In version 3.3.0 when I send files using putfile at the begining of the file different number of rows(characters) are being removed/truncated.

I tested it creating file in csv format with numbers in the column and when I send that file one time first row was row #7 next time row number 20 ect. When I downgraded to 3.2.0 this problem disappeard. Please advice

[code]


Dim filesys, localsrcdir, fil, filecoll, v3, objFTP, key
Dim passphrase, keyfile, remotedir_name, remotedir


Set filesys = CreateObject( Scripting.FileSystemObject )
Set objFTP = WScript.CreateObject( WeOnlyDo.wodSFTPCom.1 , wod_ )
Set key = WScript.CreateObject( WeOnlyDo.Keys.1 )


Const AccessingRawFile = 7
Const authPubkey = 2
Const typeDirectory = 0
const ForAppending = 8
Const Connected = 3
Const Connecting = 1
Const Disconnected = 0
Const Executing = 6
Const LogonInProgress = 2
Const Receiving = 4
Const Sending = 5

localsrcdir= SOURCEDIR

objFTP.Hostname = HOSTNAME
objFTP.Login = myUID
passphrase = mypassphrase
keyfile = KEYFILEPATH
remotedir_name = REMOTEDESTDIR


remotedir = / & remotedir_name
key.Load keyfile, CStr(passphrase)
objFTP.PrivateKey = key.PrivateKey(0)
objFTP.Authentication = authPubkey

Set localsrcdirobj = filesys.GetFolder(localsrcdir)
Set filecoll = localsrcdirobj.Files

objFTP.Blocking = 1
objFTP.Resume = True
objFTP.Connect


For Each fil in filecoll

Dim fn

fn = fil.Name
objFTP.PutFile localsrcdir & & fn, CStr(remotedir)

Next


objFTP.Disconnect


Sub wod_Connected(ErrorCode, ErrorText)

WScript.Echo Now & Connected & ErrorText

End Sub


Sub wod_Disconnected()

wScript.Echo Now & Disconnected

End Sub


Sub wod_StateChange(OldState)

Dim v3
v3 = Len(fn)

If (OldState = 7 Or OldState = 4 Or OldState = 5 ) Then
If v3 > 3 Then
wScript.Echo Now & & objFTP.StateText(OldState)
If OldState = 5 then
wScript.Echo Now & Sending file to & remotedir & / & fn
ElseIf OldState = 4 Then
wScript.Echo Now & Receiving file from & remotedir & / & fn
End If
End If
Else
wScript.Echo Now & & objFTP.StateText(OldState)
End If

End Sub


Sub wod_Done(ErrorCode, ErrorText)

If ErrorCode = 0 Then

WScript.Echo Now & File & localsrcdir & & fn & uploaded successfully to & remotedir & / & fn


Else

WScript.Echo Now & ERROR uploading file: & ErrorCode & & ErrorText

End if

End Sub

Set sysfile = Nothing
Set objFTP = Nothing
Set key = Nothing

[/code]


Complete thread: