• Re: SFTP

    From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Fri Jan 14 18:20:37 2022
    Am 20.07.2020 um 13:57 schrieb Stavros Spanos:
    Ruediger hello!

    We use FTP2 ocx from Chillcat.

    http://www.chilkatsoft.com/default.asp


    Hi Stavros,

    Can you tell me, which chilkat-modul do you use? Do you have a little
    example for me? Some code, for example?

    Thanks

    Ruediger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Fri Jan 14 18:25:35 2022
    Am 20.07.2020 um 13:57 schrieb Stavros Spanos:
    Ruediger hello!

    We use FTP2 ocx from Chillcat.

    http://www.chilkatsoft.com/default.asp

    ... By the way... I think it is not usable for commercial, is it?
    I need a solution for my customers, not for me alone...

    Ruediger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerhard Bunzel@21:1/5 to All on Sat Jan 15 00:13:15 2022
    Hi Rüdiger,

    no problem to use Chillcat for a commercial app:

    From https://www.chilkatsoft.com/licensingExplained.asp
    - The license is royalty-free, meaning that Chilkat redistributables (DLLs and shared libraries) may be included with your application's deployment/installer packages.
    - Regardless of the type of license purchased, a Chilkat component can be used in any number of applications, and can be redistributed royalty-free with your applications to end-users.
    - Licensing levels are: 1-Developer, Small Group (up to 4-Developers), and Team (up to 8 developers).


    I use this dll: https://www.weonlydo.com/SFTPdll/sftp-library-dll.asp
    - No need for installation. Copy only the dll file into the application path
    - Only 209,- US$ for a developer license.
    - Use it in asynchronous mode with events
    - 100% royalty free components

    Works great!

    Best regards

    Gerhard Bunzel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Mon Jan 17 11:04:25 2022
    Hallo Gerhard,

    Hast du vielleicht noch einen Schnipsel für mich?


    Am 15.01.2022 um 09:13 schrieb Gerhard Bunzel:
    Hi Rüdiger,

    no problem to use Chillcat for a commercial app:

    From https://www.chilkatsoft.com/licensingExplained.asp
    - The license is royalty-free, meaning that Chilkat redistributables (DLLs and shared libraries) may be included with your application's deployment/installer packages.
    - Regardless of the type of license purchased, a Chilkat component can be used in any number of applications, and can be redistributed royalty-free with your applications to end-users.
    - Licensing levels are: 1-Developer, Small Group (up to 4-Developers), and Team (up to 8 developers).


    I use this dll: https://www.weonlydo.com/SFTPdll/sftp-library-dll.asp
    - No need for installation. Copy only the dll file into the application path - Only 209,- US$ for a developer license.
    - Use it in asynchronous mode with events
    - 100% royalty free components

    Works great!

    Best regards

    Gerhard Bunzel


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerhard Bunzel@21:1/5 to All on Fri Jan 21 04:22:05 2022
    Hallo Rüdiger,

    nachfolgend etwas Code. Der ist nicht schön - zum Testen sollte das aber funktionieren.
    Wichtig ist bei den Events anscheinend der Aufruf von DoEvents() um die Nachrichten zu verarbeiten.
    Ich hatte das einfach in einer Schleife getestet. In einer richtigen Sftp-Klasse mit den Funktionen würde das natürlich anders aussehen.
    Die Funktionsaufrufe ohne die Verarbeitung der Events - einfach die Befehle nacheinander abarbeiten lassen - ist recht einfach und funktioniert gut.

    HTH

    Gerhard Bunzel


    Die DEFINES:
    DEFINE wodSFTP_typeDirectory := 0
    DEFINE wodSFTP_typeSymlink := 1
    DEFINE wodSFTP_typeFile := 2
    DEFINE wodSFTP_typeTemporary := 3
    DEFINE wodSFTP_typeUnknown := 4
    // DirItemTypes

    DEFINE wodSFTP_ZoneLocal := 0
    DEFINE wodSFTP_ZoneUTC := 1
    // TimezonesEnum

    DEFINE wodSFTP_Binary := 0
    DEFINE wodSFTP_AscII := 1
    // TransferModesEnum

    DEFINE wodSFTP_PermRead := 1
    DEFINE wodSFTP_PermWrite := 2
    DEFINE wodSFTP_PermCreate := 4
    DEFINE wodSFTP_PermTruncate := 8
    // RemotePermissions

    DEFINE wodSFTP_Disconnected := 0
    DEFINE wodSFTP_Connecting := 1
    DEFINE wodSFTP_LogonInProgress := 2
    DEFINE wodSFTP_Connected := 3
    DEFINE wodSFTP_Receiving := 4
    DEFINE wodSFTP_Sending := 5
    DEFINE wodSFTP_Executing := 6
    DEFINE wodSFTP_AccessingRawFile := 7
    // StatesEnum

    DEFINE wodSFTP_encAny := 0
    DEFINE wodSFTP_encDES := 1
    DEFINE wodSFTP_enc3DES := 2
    DEFINE wodSFTP_encAES := 3
    DEFINE wodSFTP_encBLOWFISH := 4
    DEFINE wodSFTP_encAES128 := 5
    DEFINE wodSFTP_encAES192 := 6
    DEFINE wodSFTP_encAES256 := 7
    DEFINE wodSFTP_encCAST128 := 8
    DEFINE wodSFTP_encAEScbc := 9
    DEFINE wodSFTP_encAESctr := 10
    // EncryptionsEnum

    DEFINE wodSFTP_authBoth := 0
    DEFINE wodSFTP_authPassword := 1
    DEFINE wodSFTP_authPubkey := 2
    DEFINE wodSFTP_authSecurID := 3
    DEFINE wodSFTP_authKeyboardInteractive := 4
    DEFINE wodSFTP_authGSSAPI := 5
    // AuthenticationsEnum

    DEFINE wodSFTP_ProxyNone := 0
    DEFINE wodSFTP_ProxySocks4 := 1
    DEFINE wodSFTP_ProxySocks5 := 2
    DEFINE wodSFTP_ProxyWEBStandard := 3
    DEFINE wodSFTP_ProxyRelay := 4
    DEFINE wodSFTP_ProxySocks4a := 5
    DEFINE wodSFTP_ProxyWEBNtlmAuth := 6
    DEFINE wodSFTP_ProxyWEBIntegratedAuth := 8
    // ProxyTypes

    Die DLL-Functions - nicht vollständig und auch nicht jede Funktion komplett getestet. Die fehlenden Funktionen können damit aber bestimmt selbst erstellt werden.
    _DLL FUNCTION Sftp_Create (ptrSftpEventsStruct AS PTR, pszLicenseKey AS PSZ) AS PTR PASCAL:SftpDLL.Sftp_Create
    _DLL FUNCTION Sftp_Destroy (ptrSftpDLL AS PTR) AS VOID PASCAL:SftpDLL.Sftp_Destroy
    _DLL FUNCTION Sftp_Disconnect (ptrSftpDLL AS PTR) AS LONG PASCAL:SftpDLL.Sftp_Disconnect
    _DLL FUNCTION Sftp_GetMyHostname (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetMyHostname
    _DLL FUNCTION Sftp_GetMyIP (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetMyIP
    _DLL FUNCTION Sftp_GetVersion (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetVersion
    _DLL FUNCTION Sftp_GetBlocking (ptrSftpDLL AS PTR, lValue REF LOGIC) AS LONG PASCAL:SftpDLL.Sftp_GetBlocking
    _DLL FUNCTION Sftp_SetBlocking (ptrSftpDLL AS PTR, lValue AS LOGIC) AS LONG PASCAL:SftpDLL.Sftp_SetBlocking
    _DLL FUNCTION Sftp_SetHostname (ptrSftpDLL AS PTR, pszBuffer AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetHostname
    _DLL FUNCTION Sftp_GetPort (ptrSftpDLL AS PTR, nPort REF DWORD) AS LONG PASCAL:SftpDLL.Sftp_GetPort
    _DLL FUNCTION Sftp_SetPort (ptrSftpDLL AS PTR, nPort AS DWORD) AS LONG PASCAL:SftpDLL.Sftp_SetPort
    _DLL FUNCTION Sftp_SetLogin (ptrSftpDLL AS PTR, pszBuffer AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetLogin
    _DLL FUNCTION Sftp_Connect (ptrSftpDLL AS PTR) AS LONG PASCAL:SftpDLL.Sftp_Connect
    _DLL FUNCTION Sftp_SetPassword (ptrSftpDLL AS PTR, pszBuffer AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetPassword
    _DLL FUNCTION Sftp_ListAttributes ( ptrSftpDLL AS PTR, pszRemotePath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_ListAttributes
    _DLL FUNCTION Sftp_GetListItem (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetListItem
    _DLL FUNCTION Sftp_PutFile (ptrSftpDLL AS PTR, pszLocalFile AS PSZ, pszRemotePath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_PutFile
    _DLL FUNCTION Sftp_GetFile (ptrSftpDLL AS PTR, pszLocalFile AS PSZ, pszRemoteFile AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_GetFile
    _DLL FUNCTION Sftp_GetRemotePath (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetRemotePath
    _DLL FUNCTION Sftp_SetRemotePath (ptrSftpDLL AS PTR, pszNewPath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetRemotePath
    _DLL FUNCTION Sftp_GetLocalPath (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetLocalPath
    _DLL FUNCTION Sftp_SetLocalPath (ptrSftpDLL AS PTR, pszNewPath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetLocalPath
    _DLL FUNCTION Sftp_GetClientName (ptrSftpDLL AS PTR, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetClientName
    _DLL FUNCTION Sftp_SetClientName (ptrSftpDLL AS PTR, pszNewClient AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_SetClientName
    _DLL FUNCTION Sftp_MakeDir (ptrSftpDLL AS PTR, pszRemotePath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_MakeDir
    _DLL FUNCTION Sftp_DeleteFile (ptrSftpDLL AS PTR, pszRemoteFile AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_DeleteFile
    _DLL FUNCTION Sftp_Abort (ptrSftpDLL AS PTR) AS LONG PASCAL:SftpDLL.Sftp_Abort _DLL FUNCTION Sftp_GetState (ptrSftpDLL AS PTR, nState REF DWORD) AS LONG PASCAL:SftpDLL.Sftp_GetState
    _DLL FUNCTION Sftp_GetStateText (ptrSftpDLL AS PTR, nState AS DWORD, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetStateText
    _DLL FUNCTION Sftp_GetErrorText (ptrSftpDLL AS PTR, nErrorCode AS SHORT, pszBuffer AS PSZ, nSize REF LONG) AS LONG PASCAL:SftpDLL.Sftp_GetErrorText
    _DLL FUNCTION Sftp_GetLastError (ptrSftpDLL AS PTR, nErrorCode REF SHORT) AS LONG PASCAL:SftpDLL.Sftp_GetLastError
    _DLL FUNCTION Sftp_SetTransferMode((ptrSftpDLL AS PTR, nValue AS SHORT) AS LONG PASCAL:SftpDLL.Sftp_SetTransferMode
    _DLL FUNCTION Sftp_ListNames ( ptrSftpDLL AS PTR, pszRemotePath AS PSZ) AS LONG PASCAL:SftpDLL.Sftp_ListNames

    Die Structure für die Events:
    STRUCT SftpEventsStruct
    MEMBER hConnected AS PTR
    MEMBER hDisconnected AS PTR
    MEMBER hStateChange AS PTR
    MEMBER hHostFingerprint AS PTR
    MEMBER hProgress AS PTR
    MEMBER hListItems AS PTR
    MEMBER hDone AS PTR
    MEMBER hAttributes AS PTR
    MEMBER hCryptoInformation AS PTR
    MEMBER hAttributesData AS PTR
    MEMBER hLoginChallenge AS PTR
    MEMBER hLoopItem AS PTR
    MEMBER hLoopError AS PTR
    MEMBER hRemoteData AS PTR
    MEMBER hExtendedCmdReply AS PTR

    Die Prozeduren für den Empfang der Events:
    PROCEDURE Sftp_Done (hWnd AS PTR, nErrorCode AS SHORT, pErrorText AS PSZ)

    // _dOut(#Sftp_Done, hWnd, nErrorCode, pErrorText)

    RETURN

    PROCEDURE Sftp_Disconnected (hWnd AS PTR)

    // _dOut(#Sftp_Disconnected, hWnd)

    RETURN

    PROCEDURE Sftp_Connected (hWnd AS PTR, nErrorCode AS SHORT, pErrorText AS PSZ)

    // _dOut(#Sftp_Connected, hWnd, nErrorCode, Psz2String(pErrorText))

    RETURN

    PROCEDURE Sftp_StateChange (hWnd AS PTR, nOldState AS LONG)

    // _dOut(#Sftp_StateChange, hWnd, nOldState)

    RETURN

    PROCEDURE Sftp_Progress (hWnd AS PTR, param1, param2)
    // (hWnd AS PTR, nPosition AS I64Rec, nTotal AS I64Rec) AS VOID CALLBACK
    // Mit den 64Bit-Parametern noch nicht getestet!!!!

    // _dOut(#Sftp_Progress, hWnd, param1, param2)

    RETURN


    Etwas Code aus meinen Tests. Die Umschaltung zwischen 'normalem Funktionsaufruf' und 'ASync-Modus mit Events' erfolgt mit dem 'Sftp_SetBlocking()' und dem Sftp_Create() mit oder ohne erstem Parameter.

    TEXTBLOCK Sample
    LOCAL pSftpDLL AS PTR
    LOCAL pBuf1, pBuf2 AS PSZ
    LOCAL i, nCount AS INT
    LOCAL nState AS DWORD
    LOCAL nRet AS LONG
    LOCAL cRet AS STRING
    LOCAL nError AS SHORT
    // LOCAL lRet AS LOGIC
    LOCAL pEvent IS SftpEventsStruct

    // LOCAL struFindData IS _winWIN32_FIND_DATA

    nCount := 0

    pEvent.hConnected := @Sftp_Connected ()
    pEvent.hDisconnected := @Sftp_Disconnected ()
    pEvent.hDone := @Sftp_Done ()
    pEvent.hStateChange := @Sftp_StateChange ()
    pEvent.hProgress := @Sftp_Progress ()

    // pSftpDLL := Sftp_Create(NULL_PTR, String2Psz("LizenzKey"))
    pSftpDLL := Sftp_Create(@pEvent, String2Psz("LizenzKey"))
    pBuf1 := MemAlloc(10240)
    pBuf2 := MemAlloc(1024)
    MemSet(pBuf1, 0, 10240)
    MemSet(pBuf2, 0, 1024)
    i := 1024
    nRet := Sftp_GetMyIP(pSftpDLL, pBuf2, @i)
    cRet := Psz2String(pBuf2)
    nRet := Sftp_GetMyHostname(pSftpDLL, pBuf2, @i)
    cRet := Psz2String(pBuf2)

    // Test zum Setzen und Lesen von Sftp_SetBlocking()
    // nRet := Sftp_SetBlocking(pSftpDLL, TRUE)
    // nRet := Sftp_GetBlocking(pSftpDLL, @lRet)
    nRet := Sftp_SetBlocking(pSftpDLL, FALSE)
    // nRet := Sftp_GetBlocking(pSftpDLL, @lRet)
    // nRet := Sftp_SetBlocking(pSftpDLL, TRUE)

    nRet := Sftp_SetHostname(pSftpDLL, String2Psz("www.MyServer.com"))
    nRet := Sftp_SetLogin(pSftpDLL, String2Psz("MyTest"))

    i := 1024
    nRet := Sftp_GetVersion(pSftpDLL, pBuf2, @i)
    cRet := Psz2String(pBuf2)
    nRet := Sftp_SetPassword(pSftpDLL, String2Psz("MyPassword"))

    nRet := Sftp_SetPort(pSftpDLL, 202)

    // Status abfragen
    nRet := Sftp_GetState(pSftpDLL, @nState)
    i := 1024
    nRet := Sftp_GetStateText(pSftpDLL, nState, pBuf2, @i)
    cRet := Psz2String(pBuf2)

    nRet := Sftp_GetLastError(pSftpDLL, @nError)
    i := 1024
    nRet := Sftp_GetErrorText(pSftpDLL, nError, pBuf2, @i)
    _dOut(pBuf2)

    i := Sftp_Connect(pSftpDLL)

    // Eine Schleife um die Events zu testen.
    DO WHILE nCount <= 100
    // nRet := Sftp_GetState(pSftpDLL, @nState)
    // _dOut(nState)
    // IF nState==3
    // EXIT
    // ENDIF
    // ApplicationExec(EXECWHILEEVENT)
    DoEvents()
    Sleep(100)
    nCount++
    ENDDO

    nRet := Sftp_GetState(pSftpDLL, @nState)
    _dOut(nState)

    IF nState == 3
    // IF i == 0
    nRet := Sftp_GetState(pSftpDLL, @nState)

    nRet := Sftp_ListAttributes(pSftpDLL, String2Psz("/home/longtest"))
    i := 10240
    nRet := Sftp_GetListItem(pSftpDLL, pBuf1, @i)
    _dOut(pBuf1)
    SaveFile("sftp_dir_1.txt", Psz2String(pBuf1))

    nRet := Sftp_PutFile(pSftpDLL, String2Psz("C:\MyTest\TestFile.txt"), String2Psz("/home/longtest"))

    nRet := Sftp_ListAttributes(pSftpDLL, String2Psz("/home/longtest"))
    i := 10240
    nRet := Sftp_GetListItem(pSftpDLL, pBuf1, @i)
    _dOut(pBuf1)
    SaveFile("sftp_dir_2.txt", Psz2String(pBuf1))
    ELSE
    nRet := Sftp_GetLastError(pSftpDLL, @nError)
    i := 1024
    nRet := Sftp_GetErrorText(pSftpDLL, nError, pBuf2, @i)
    _dOut(pBuf2)
    ENDIF
    nRet := Sftp_Disconnect(pSftpDLL)
    Sftp_Destroy(pSftpDLL)

    MemFree(pBuf1)
    MemFree(pBuf2)

    RETURN NIL

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Mon Jan 24 15:01:30 2022
    Super, danke dir!
    Ich werde das mal in Ruhe testen und gebe dir dann Rückmeldung.

    LG Rüdiger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Mon Jan 24 20:52:31 2022
    Hallo Gerhard,

    Jetzt musst du mir doch nochnmal helfen.

    Ich habe deinen Code probiert, aber ich bekomme immer einen Fehler: "Der Prozedureinsprungspunkt wurde nicht gefunden....."

    Wahrscheinlich lädt er die DLL nicht richtig. Kannst du mir da noch
    einen Tipp geben?

    Rüdiger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerhard Bunzel@21:1/5 to All on Tue Jan 25 06:32:14 2022
    Hallo Rüdiger,

    ist die Datei SftpDLL.dll im gleichen Verzeichnis wie die EXE-Datei?

    Gerhard

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?R=c3=bcdiger_Fresemann?=@21:1/5 to All on Wed Jan 26 08:34:24 2022
    Hallo Gerhard,

    Ich glaube, ich habs gefunden. Ich denke, du benutzt ein anderes Produkt
    wie ich. Bei mir heißt die DLL wodSFTP.dll und ist von WeOnlyDo.

    So What, ich habe einen anderern Weg gefunden:

    - Die DLL wird über regsvr32 in Windows registriert.
    - Nun kann ich die DLL über OLEAutoObject in Cavo einbinden.
    - Ich erreiche nun alle Funktionen bequem, außer die Events.
    - Die wichtigen Funktionen, wo ich ein Event haben möchte habe ich in
    einen ErrorBlock() gepackt und mir einen Exception Handler gebastelt.
    - Durch die Handler-Parameter im Codeblock kann ich die Eventergebnisse abfragen (etwas eingeschränkt, aber brauchbar)

    So klappt es relativ gut mit wenig aufwand ohne Painter,
    Automationserver oder sonst was. Das hält der Pflegeaufwand ebenfalls
    gering.

    Trotzdem Danke für deinen Code, ein paar interessante Ideen hat er für
    mich dennoch enthalten.

    Rüdiger

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerhard Bunzel@21:1/5 to All on Wed Jan 26 09:42:41 2022
    Hallo Rüdiger,

    Bei mir heißt die DLL wodSFTP.dll und ist von WeOnlyDo.
    Dann benutzt Du wodSFTP ActiveX component.
    Ich benutze die in meinem Link angegebene wodSFTPdll - die DLL-Version davon.

    Der Vorteil der DLL-Version ist nach meiner Meinung, die muss nicht installiert werden - einfach in das Programmverzeichnis kopieren - fertig.
    Keine Installation - keine Registrierung der DLL. Auch wenn der User keine Installationsrechte hat, kann die Funktion genutzt werden.

    Gerhard

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)