Progress indicator within a script?

Advertisement

Fox
Joined:
Posts:
2

Progress indicator within a script?

When I run the winscp.com and do open mysession and then get file.ext I get a nice indicator for the download process, but when I do the same within a script it just stands there blinking until it's done and then it prints all that happened.

Is there a way to get it to show a more "live" progress within a script?

My script is in JS if that matters.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: Progress indicator within a script?

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.

Reply with quote

Fox

Ok thanks! I'll try that once it's out then.

Right now I went around the problem by creating a batch file that start WinSCP.exe with all the parameters I need and run that from within the script instead of directly running the command. Not as pretty but it works. :)

Reply with quote

aerze
Joined:
Posts:
1
Location:
San Diego

Re: Progress indicator within a script?

martin wrote:

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.

The Session.FileTransferProgress Event won't fire.
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');
}

Am I implementing this wrong? I'm having a hard time finding any JScript examples.

BTW If you don't mind, I could JScript examples for the site.
This tool has been super useful so far.

Reply with quote

jbratten
Joined:
Posts:
2

FileTransferProgress also not firing in VBA

I too find that FileTransferred fires after each file, but FileTransferProgress does not fire at all.
WinSCP Ver. 5.5.1 Build 3970
WinSCPNet Ver. 5.5.1 (at least that's what the zip file is named)
Windows XP and 7
VBA in Access 2003/2007 and Excel 2007

The file transfer occurs and completes without any errors or problems. Just no progress updates.

'// 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

Thanks

Reply with quote

Advertisement

BoringPortlander
Guest

Trying to see progress within VB.Net program as well

I am trying to figure this out as well. I want to add a simple dialog bog with a progress bar while I run a Syncronization with the newest WinSCPNet.dll libs

Any help would be appreciated

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: FileTransferProgress Event in VBA

jbratten wrote:

The development version fixed the issue for me in VBA (Access, etc).

Thank you for the prompt response and fix.
Thanks for your feedback.

Reply with quote

Advertisement

xscraper
Guest

Re: Progress indicator within a script?

martin wrote:

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.

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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: Progress indicator within a script?

xscraper wrote:

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.
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.
But, WinSCP 5.5.2 will be released today and as part of that we are taking over "WinSCP" NuGet package and will be keeping it up to date.
https://www.nuget.org/packages/WinSCP/
https://winscp.net/tracker/1145

Reply with quote

Advertisement

You can post new topics in this forum