Progress indicator within a script?
Is there a way to get it to show a more "live" progress within a script?
My script is in JS if that matters.
Advertisement
Advertisement
WinSCP does not print progress to redirected output.
With upcoming 5.2 you can use WinSCP .NET assembly from your JS and handle Session.FileTransferProgress event.
var zvSession = WScript.CreateObject('WinSCP.Session','sessionEvent_'); // This event won't fire function sessionEvent_FileTransferProgress(sender, args) { WScript.echo('start'); } // Although this one does function sessionEvent_FileTransferred(sender, args) { WScript.echo(args.FileName); WScript.echo('end'); }
'// Instantiate Class Sub testEDI() Dim objEDI As New OfficeEDI objEDI.doXfer End Sub '// Class OfficeEDI Option Compare Database Private WithEvents objSession As WinSCPnet.Session Public Sub doXfer() Dim objOptions As New WinSCPnet.SessionOptions Set objSession = New WinSCPnet.Session objOptions.Protocol = Protocol_Sftp objOptions.Portnumber = 30 objOptions.hostname = "@xxx.xxx.xxx.xxx" objOptions.UserName = "test" objOptions.Password = "xxxxxxxx" objOptions.SshHostKeyFingerprint = "ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" objSession.Open objOptions If objSession.opened Then Debug.Print "Session Opened" objSession.putfiles "F:\FileName*", "//Test//*", False End If objSession.dispose Set objOptions = Nothing Set objSession = Nothing End Sub Private Sub objSession_FileTransferProgress(ByVal sender As Object, ByVal e As FileTransferProgressEventArgs) Debug.Print Format(e.overallprogress, "Percent") End Sub Private Sub objSession_FileTransferred(ByVal sender, ByVal e As TransferEventArgs) Debug.Print e.FileName & " To " & e.destination End Sub
Advertisement
Thanks for your feedback.The development version fixed the issue for me in VBA (Access, etc).
Thank you for the prompt response and fix.
Advertisement
Thanks for your reports.
This bug has been added to the tracker:
https://winscp.net/tracker/1134
I'll send dev version with fix for testing to registered reporters.
What NuGet package? Anyway, no NuGet package is maintained by WinSCP team. They are all outdated. You should download the .NET assembly from this site.I just got the WinSCP .Net library from Nuget and I used it in my code. I also do not see FileTransferProgress event in the Session class. How do I get the latest build where the bug is fixed? Thanks a lot.
Advertisement
You can post new topics in this forum