FTP: Request to share samples

FTP: Request to share samples

Postby nageswaragunupudi » Wed Apr 28, 2021 1:08 pm

Many of our colleagues are successfully using different approaches to upload/download files to/from FTP Servers and also to manage folders and files on FTP servers.

At the same time, there are also some users who are seeking such solutions.

We thought of pooling all approaches used by different users under one thread for the benefit of all members of our community.

We, therefore, request all those friends who are using FTP, to consider sharing their knowledge with others by posting some sample programs here.

Thanking you all in advance.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FTP: Request to share samples

Postby RAMESHBABU » Wed Apr 28, 2021 1:25 pm

Hi Friends,
These are the ftp functions, I have been using to Upload/Download files, past several years with out any fail:

UPLDDNLD.PRG :

Code: Select all  Expand view

#include "fivewin.ch"

// File Attributes
#define FILE_ATTRIBUTE_READONLY                         1
#define FILE_ATTRIBUTE_HIDDEN                           2
#define FILE_ATTRIBUTE_SYSTEM                           4
#define FILE_ATTRIBUTE_DIRECTORY                       16
#define FILE_ATTRIBUTE_ARCHIVE                         32
#define FILE_ATTRIBUTE_NORMAL                         128
#define FILE_ATTRIBUTE_TEMPORARY                      256

// Access Types for InternetOpen()
#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS

// Manifests
#define INTERNET_INVALID_PORT_NUMBER                    0   // use the protocol-specific default
#define INTERNET_DEFAULT_FTP_PORT                      21   // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT                   70   //    "     " gopher "
#define INTERNET_DEFAULT_HTTP_PORT                     80   //    "     " HTTP   "
#define INTERNET_DEFAULT_HTTPS_PORT                   443   //    "     " HTTPS  "
#define INTERNET_DEFAULT_SOCKS_PORT                  1080   // default for SOCKS firewall servers.

// Service Types for InternetConnect()
#define INTERNET_SERVICE_FTP                            1
#define INTERNET_SERVICE_GOPHER                         2
#define INTERNET_SERVICE_HTTP                           3

// Flags for FTP
#define INTERNET_FLAG_TRANSFER_ASCII                    1
#define INTERNET_FLAG_TRANSFER_BINARY                   2

// File Access Types
#define GENERIC_READ                           2147483648
#define GENERIC_WRITE                          1073741824

STATIC cFtpSite, cFtpUserName, cFtpPassword, cDestination

FUNCTION Main()

LOCAL lOk := .F.

cFtpSite     := "ftp.FtpSite.com"
cFtpUserName := "abcd@FtpSite.com"
cFtpPassword := "xyz@12345"
cDestination := "/MyDestinationFolder/"

* 1 Upload
lOk := UpLoadDownLoad(1, {"uplddnld.prg"}, cDestination, "UPLDDNLD.PRG")

* 2 Download
UpLoadDownLoad(2, {cDestination+"/uplddnld.prg"}, "C:\FWH\SAMPLES\", "UPLDDNLD.PRG")

RETURN nil

*******************************************************************************
*** FUNCTION UpLoadDownLoad(nOpt) - Upload / Download Data to/from FTP Site ***
*******************************************************************************

FUNCTION UpLoadDownLoad(nUpDown, aDataFiles, cDestination, cDataName, lAuto)

LOCAL oBrush, oDlg, oGroup, oGroup1, oGroup2
LOCAL oMeter1, oMeter2, nMeter1, nMeter2, cTitle
LOCAL aUpLoadFiles := {}, aDownLoadFiles := {}
LOCAL bAction, lOk := .F., lIsInternet := .F.
LOCAL aGradiate := { { .25, nRgb( 152,194,152 ), CLR_WHITE }, { .75,CLR_WHITE, nRgb( 152,194,152 ) } }

DEFAULT lAuto := .F.

MsgInfo("
Trying to connect to Internet. Please wait...")

lIsInternet := IsInterNet()

IF !lIsInternet
   RETURN .F.
ENDIF

IF nUpDown = 1
   IF !lAuto
      aUpLoadFiles   := ACLONE(aDataFiles)
      cTitle         := "
Uploading Data. Please wait..."
      bAction        := {||lOk := FtpUpLoad(  cFtpSite,       ;
                                              cFtpUsername,   ;
                                              cFtpPassword,   ;
                                              oMeter1,        ;
                                              oMeter2,        ;
                                              aUpLoadFiles,   ;
                                              cDestination,   ;
                                              cDataName,      ;
                                              lAuto, oDlg)}
   ELSE

      aUpLoadFiles   := ACLONE(aDataFiles)
      lOk := FtpUpLoad( cFtpSite, cFtpUsername, cFtpPassword, ;
                        oMeter1, oMeter2, aUpLoadFiles,       ;
                        cDestination, cDataName, lAuto)
  ENDIF
ELSE
   IF !lAuto
      aDownLoadFiles := ACLONE(aDataFiles)
      cTitle         := "
Downloading Data. Please wait..."
      bAction        := {||lOk := FtpDownLoad(cFtpSite,       ;
                                              cFtpUsername,   ;
                                              cFtpPassword,   ;
                                              oMeter1,        ;
                                              oMeter2,        ;
                                              aDownLoadFiles, ;
                                              cDestination,   ;
                                              cDataName,      ;
                                              lAuto,oDlg)}
  ELSE
      lOk := FtpDownLoad(cFtpSite, cFtpUsername, cFtpPassword,;
                         oMeter1, oMeter2, aDownLoadFiles,    ;
                         cDestination, cDataName, lAuto, oDlg)
  ENDIF
ENDIF

IF !lAuto

   DEFINE BRUSH oBrush GRADIENT aGradiate

   DEFINE DIALOG oDlg RESOURCE "
CONNECT"                     ;
          COLORS CLR_BLACK, nRGB(250,239,247)                ;
          TRANSPARENT BRUSH oBrush

   oDlg:cTitle := cTitle

   REDEFINE GROUP   oGroup  ID 301 OF oDlg TRANSPARENT COLOR CLR_HRED

   REDEFINE GROUP   oGroup1 ID 302 OF oDlg TRANSPARENT COLOR CLR_HBLUE
   REDEFINE METEREX oMeter1 VAR nMeter1 ID 101 OF oDlg

   REDEFINE GROUP   oGroup2 ID 303 OF oDlg TRANSPARENT COLOR CLR_HBLUE
   REDEFINE METEREX oMeter2 VAR nMeter2 ID 102 OF oDlg                               ;
            GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) }  ,;
                             { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235, 173 ) } } ;
            GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) }  ,;
                             { 1/2, nRGB( 224, 238, 237 ), nRGB( 224, 238, 237 ) } } ;

   * This block gets evaluated only the first time the DialogBox is painted !!!
   oDlg:bStart := {||(Eval( bAction), SysWait(1), oDlg:End())}

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE BRUSH oBrush

   RETURN lOk

ENDIF

RETURN lOk

*******************************************************************************
*** STATIC FUNCTION UpLoad(oMeter, cSourceFile, cDestination)               ***
*******************************************************************************

STATIC FUNCTION FTPUpLoad(cFtpSite, cUsername, cPassword, oMeter1, oMeter2,   ;
                          aSourceFiles, cDestination, cDataName, lAuto,       ;
                          oDlg)

LOCAL hInternet, hConnect, hSource, hDest, nRead
LOCAL cSourceFile, cData := SPACE( 32768 ) //cData := SPACE( 1024 )
LOCAL nPos  := 0, n, lSucess := .T., nTotal := 0

hInternet   := InternetOpen( "
Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )

hConnect    := InternetConnect( hInternet, cFtpSite, INTERNET_INVALID_PORT_NUMBER,;
                                cUsername, cPassword, INTERNET_SERVICE_FTP, 0, 0 )

IF !lAuto
   oMeter1:Set( 0 )
   oMeter1:nTotal := LEN(aSourceFiles)
ENDIF

FOR n = 1 TO LEN(aSourceFiles)

    cSourceFile := SUBSTR(aSourceFiles[n],RAT("
\",aSourceFiles[n])+1)
    hDest       := FtpOpenFile( hConnect, cDestination+cSourceFile, GENERIC_WRITE, 0, 0 )

    nTotal := FSize(aSourceFiles[n])

    IF !lAuto
       oMeter2:Set( 0 )
       oMeter2:nTotal := nTotal
    ENDIF

    hSource := FOpen(aSourceFiles[n])

    WHILE .T.

      nRead := FRead( hSource, @cData, LEN( cData ) )

      IF nRead = 0
         IF FERROR() # 0
            lSucess := .F.
         ENDIF
         EXIT
      ENDIF
      IF !InternetWriteFile( hDest, @cData, nRead )
         lSucess := .F.
         EXIT
      ELSE
         nPos += LEN( cData )
         IF !lAuto
            oMeter2:Set( nPos )
         ENDIF
      ENDIF

    ENDDO

    IF !lAuto
       oMeter1:Set( n )
    ENDIF

    FClose( hSource )
    InternetCloseHandle( hDest )

    SysRefresh()

    IF .NOT. lSucess
       EXIT
    ENDIF

NEXT

InternetCloseHandle( hConnect )
InternetCloseHandle( hInternet )

SysRefresh()

IF .NOT. lAuto
   IF lSucess
      MsgInfo(cDataName+"
has been Uploaded Successfully.")
   ELSE
      MsgInfo("
Error in Uploading "+cDataName+".")
   ENDIF
ENDIF

IF !lAuto
   oMeter2:Set( 0 )
   oMeter1:Set( 0 )
   oDlg:End()
ENDIF

RETURN lSucess

*******************************************************************************
*** STATIC FUNCTION DownLoad( oMeter, cSourceFile, cDestFile )              ***
*******************************************************************************

STATIC FUNCTION FTPDownLoad(cFtpSite, cUsername, cPassword, oMeter1, oMeter2, ;
                            aSourceFiles, cDestFile, cDataName, lAuto,        ;
                            oDlg)

LOCAL hInternet, hConnect, hSource, hDest, nRead
LOCAL cSourceFile, cData := SPACE( 32768 ) //cData := SPACE( 1024 )

LOCAL nPos  := 0, n, lSucess := .T.

hInternet   := InternetOpen( "
Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
hConnect    := InternetConnect( hInternet, cFtpSite, INTERNET_INVALID_PORT_NUMBER,;
                                cUsername, cPassword, INTERNET_SERVICE_FTP, 0, 0 )
IF !lAuto
   oMeter1:Set( 0 )
   oMeter1:nTotal := LEN(aSourceFiles)
ENDIF

FOR n = 1 TO LEN(aSourceFiles)

    cSourceFile := aSourceFiles[n]
    hSource     := FtpOpenFile( hConnect, cSourceFile, GENERIC_READ, 0, 0 )

    IF !lAuto
       oMeter2:Set( 0 )
       oMeter2:nTotal := FtpGetFileSize( hSource )
    ENDIF

    hDest := FCreate( cDestFile+SUBSTR(cSourceFile,RAT("
/",cSourceFile)+1) )

    WHILE .T.

      nRead := InternetReadFile( hSource, @cData )

      IF nRead = -1
         lSucess := .F.
         EXIT
      ENDIF

      IF nRead = 0
         EXIT
      ENDIF

      FWRITE( hDest, cData, nRead )

      nPos += LEN(ALLTRIM(cData))

      IF !lAuto
         oMeter2:Set( nPos )
      ENDIF

    ENDDO

    FClose( hDest )
    InternetCloseHandle( hSource )
    SysRefresh()

    IF !lAuto
       oMeter1:Set( n )
    ENDIF

    IF .NOT. lSucess
       EXIT
    ENDIF

NEXT

InternetCloseHandle( hConnect )
InternetCloseHandle( hInternet )

SysRefresh()

IF .NOT. lAuto
   IF lSucess
      MsgInfo(cDataName+"
has been Downloaded Successfully.")
   ELSE
      MsgInfo("
Error in Downloading "+cDataName+".")
   ENDIF
ENDIF

IF !lAuto
   oMeter2:Set( 0 )
   oMeter1:Set( 0 )
   oDlg:End()
ENDIF

RETURN lSucess

*******************************************************************************
*** FTP Upload/Download FUNCTION Wrappers of WININET.LIB                    ***
*******************************************************************************

#pragma BEGINDUMP

#include "
windows.h"
#include "
wininet.h"
#include "
hbapi.h"

HB_FUNC( INTERNETOPEN )
{
    hb_retnl( ( LONG ) InternetOpen( hb_parc( 1 ), hb_parnl( 2 ), hb_parc( 3 ), hb_parc( 4 ), hb_parnl( 5 ) ) );
}

//***********************

HB_FUNC( INTERNETCLOSEHANDLE )
{
    hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}

//***********************

HB_FUNC( INTERNETCONNECT )
{
    hb_retnl( ( LONG ) InternetConnect( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), ( INTERNET_PORT ) hb_parnl( 3 ), hb_parc( 4 ), hb_parc( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) ) );
}

//***********************

HB_FUNC( FTPOPENFILE )
{
    hb_retnl( ( LONG ) FtpOpenFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}

//***********************

HB_FUNC( FTPGETFILESIZE )
{
    DWORD nFileSizeHigh;

    hb_retnl( ( LONG ) FtpGetFileSize( ( HINTERNET ) hb_parnl( 1 ), &nFileSizeHigh ) );
}

//***********************

HB_FUNC( INTERNETREADFILE )
{
    DWORD nBytesRead;

    BOOL lSuccess = InternetReadFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parclen( 2 ), &nBytesRead );

    if ( !lSuccess )
        hb_retnl( -1 );
    else
        hb_retnl( nBytesRead );
}

//***********************

HB_FUNC( INTERNETWRITEFILE )
{
    DWORD nBytesWritten;

    BOOL lSuccess = InternetWriteFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parnl( 3 ), &nBytesWritten );

    hb_retl( lSuccess );
}


HB_FUNC( FTPGETFILE )
{
    hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );
}

HB_FUNC( FTPPUTFILE )
{
    hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}

HB_FUNC( FTPDELETEFILE )
{
    hb_retl( FtpDeleteFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

HB_FUNC( FTPCREATEDIRECTORY )
{
    hb_retl( FtpCreateDirectory( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

HB_FUNC( FTPREMOVEDIRECTORY )
{
    hb_retl( FtpRemoveDirectory( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

HB_FUNC( FTPFINDFIRSTFILE )
{
    hb_retnl( ( LONG ) FtpFindFirstFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ), ( WIN32_FIND_DATA * ) hb_parc( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) ) );
}

HB_FUNC( INTERNETFINDNEXTFILE )
{
    hb_retl( InternetFindNextFile( ( HINTERNET ) hb_parnl( 1 ), hb_parc( 2 ) ) );
}

#pragma ENDDUMP


UPLDDNLD.RC :

Code: Select all  Expand view


CONNECT DIALOG 25, 31, 255, 97
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Connecting to Modem..."
FONT 8, "MS Sans Serif"
{
 GROUPBOX "Upload/Download", 301, 8, 6, 239, 81, BS_GROUPBOX
 GROUPBOX "Total Data", 302, 15, 15, 225, 31, BS_GROUPBOX
 CONTROL "TMeterEx", 101, "TMeterEx", 0 | WS_CHILD | WS_VISIBLE, 22, 25, 210, 14
 GROUPBOX "Individual Data", 303, 15, 49, 225, 31, BS_GROUPBOX
 CONTROL "TMeterEx", 102, "TMeterEx", 0 | WS_CHILD | WS_VISIBLE, 22, 59, 210, 14
}

 


I hope, they are useful to the needy.

Please ensure that 'WININET.LIB' from BCC? / LIB folder is added in the link Script.

-Ramesh Babu
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: FTP: Request to share samples

Postby Antonio Linares » Wed Apr 28, 2021 2:42 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FTP: Request to share samples

Postby hmpaquito » Wed Apr 28, 2021 4:11 pm

Every day the use of SFTP is more required. FTP is less and less used
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FTP: Request to share samples

Postby Antonio Linares » Wed Apr 28, 2021 4:43 pm

Paco,

thanks

I guess you mean FTPS and not SFTP
SFTP (SSH File Transfer Protocol), not to be confused with FTPS (Secure FTP), runs on top of the SSH (Secure Shell) protocol


edited: I just tested Harbour hbtip connecting to a FTPS server and these lines worked as expected:

local oUrl := TUrl():New( "ftps://username:password@domainname.com" )

? oUrl:cProto
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FTP: Request to share samples

Postby Antonio Linares » Wed Apr 28, 2021 5:14 pm

a very good FTP example using Harbour contrib hbtip.lib:

viewtopic.php?p=240801#p240801
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FTP: Request to share samples

Postby hmpaquito » Wed Apr 28, 2021 5:24 pm

SFTP (SSH File Transfer Protocol) is a secure file protocol that is used to access, manage, and transfer files over an encrypted SSH transport. When compared with the traditional FTP protocol, SFTP offers all the functionality of FTP, but it is more secure and easier to configure.


Antonio Linares wrote:Paco,

thanks

I guess you mean FTPS and not SFTP
SFTP (SSH File Transfer Protocol), not to be confused with FTPS (Secure FTP), runs on top of the SSH (Secure Shell) protocol


edited: I just tested Harbour hbtip connecting to a FTPS server and these lines worked as expected:

local oUrl := TUrl():New( "ftps://username:password@domainname.com" )

? oUrl:cProto
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FTP: Request to share samples

Postby nageswaragunupudi » Wed Apr 28, 2021 8:40 pm

hmpaquito wrote:SFTP (SSH File Transfer Protocol) is a secure file protocol that is used to access, manage, and transfer files over an encrypted SSH transport. When compared with the traditional FTP protocol, SFTP offers all the functionality of FTP, but it is more secure and easier to configure.


Antonio Linares wrote:Paco,

thanks

I guess you mean FTPS and not SFTP
SFTP (SSH File Transfer Protocol), not to be confused with FTPS (Secure FTP), runs on top of the SSH (Secure Shell) protocol


edited: I just tested Harbour hbtip connecting to a FTPS server and these lines worked as expected:

local oUrl := TUrl():New( "ftps://username:password@domainname.com" )

? oUrl:cProto


Thank you.
Would you like to share with other users how are you using SFTP, please?
Thanks in advance.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FTP: Request to share samples

Postby hmpaquito » Wed Apr 28, 2021 8:43 pm

Hello Mr. Nages,

On one occasion I was required to use SFTP. I searched and searched in Fwh and Harbour and found no way. I finally had to rely on FTP

Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FTP: Request to share samples

Postby mag071 » Thu Apr 29, 2021 6:21 pm

Saludos ;
Ejemplo donde use un PaintCircularMeter( ) dentro del ftp para pintar mientras se sube.

Code: Select all  Expand view

METHOD EnviaFtp(cFileaEnviar,cFileComplet) CLASS TElot
LOCAL cUrl,cUL
LOCAL oSelf:=SELF

curl_global_init()
cUrl := curl_easy_init()
hb_default( @cUL, "ftp://107.180.57.119/"+cFileaEnviar )
curl_easy_setopt( curl, HB_CURLOPT_URL, cUL )
curl_easy_setopt( cUrl, HB_CURLOPT_UPLOAD )
curl_easy_setopt( Curl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( curl, HB_CURLOPT_UL_FILE_SETUP, cFileComplet )
curl_easy_setopt( curl, HB_CURLOPT_INFILESIZE, hb_vfSize(cFileComplet) )
curl_easy_setopt( curl, HB_CURLOPT_USERPWD, "guaicarbackup@guaicar.com.ve:TuClaveFTP" )
curl_easy_setopt( Curl, HB_CURLOPT_FAILONERROR, .T. )
curl_easy_setopt( Curl, HB_CURLOPT_FILETIME, .T. )
curl_easy_setopt( curl, HB_CURLOPT_XFERINFOBLOCK, {| nPos, nLen | PaintCircularMeter( oSelf:oWndZion:oWndClient, {130,30,430,330}, 0.5, nPos, nLen, ;
                                                     { RGB( 0, 68, 118 ),Rgb( 237,165,12 )  } ) ;
                                                    } )
curl_easy_setopt( Curl, HB_CURLOPT_NOPROGRESS, 0 )
curl_easy_setopt( Curl, HB_CURLOPT_VERBOSE, .F. )
curl_easy_perform( cUrl )

Return self

 
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: FTP: Request to share samples

Postby Enrico Maria Giordano » Thu Apr 29, 2021 9:06 pm

I successful used psftp.exe (part of Putty):

Code: Select all  Expand view
https://www.puttygen.com/psftp


Code: Select all  Expand view
FUNCTION SFTP( cSrv, cPrt, cUsr, cPsw, cFil )

    LOCAL lOk

    MEMOWRIT( "psftp.cmd", "put " + cFil, .F. )

    lOk = WAITRUN( "psftp " + cSrv + " -P " + cPrt + " -l " + cUsr + " -pw " + cPsw + " -b psftp.cmd", SW_HIDE ) = 0

    FERASE( "psftp.cmd" )

    RETURN lOk


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP: Request to share samples

Postby hmpaquito » Fri Apr 30, 2021 7:00 am

thks mr. Enrico

BTW, is it possible obtain PSFTP command result ? success or not success ? how to ?
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FTP: Request to share samples

Postby Enrico Maria Giordano » Fri Apr 30, 2021 7:50 am

I don't know. Please experiment with psftp.exe.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FTP: Request to share samples

Postby Antonio Linares » Fri Apr 30, 2021 8:08 am

New Harbour and mod_harbour FTP upload using Curl example based on Mario's post and on mod_harbour callphp.prg example:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/ftpup.prg

Working fine. You can test it from mod_harbour live examples:
https://www.modharbour.org/modharbour_samples/ftpup.prg

Now we need a SFTP server... :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FTP: Request to share samples

Postby hmpaquito » Fri Apr 30, 2021 8:29 am

Antonio Linares wrote:Now we need a SFTP server... :-)



Here you are: https://www.sftp.net/public-online-sftp-servers
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests