Page 2 of 2

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 8:50 am
by cnavarro
Antonio
remove this lines for only return list of files
Code: Select all  Expand view

      curl_easy_setopt( hCurl, HB_CURLOPT_UPLOAD )
      curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
      curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) )
 


Add
Code: Select all  Expand view

curl_easy_setopt( hCurl, HB_CURLOPT_DIRLISTONLY, 1 )
 


and for SFTP, it's neccesary
Code: Select all  Expand view

curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
 


and, this is important also
Code: Select all  Expand view

curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
 


Full sample for directory files and conexion to SFTP
Code: Select all  Expand view

curl_global_init()

   if ! empty( hCurl := curl_easy_init() )
      curl_easy_setopt( hCurl, HB_CURLOPT_PORT, cPort )     // default 22
      curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
      curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
      curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "username:password" )
      curl_easy_setopt( hCurl, HB_CURLOPT_FAILONERROR, .T. )
      curl_easy_setopt( hCurl, HB_CURLOPT_FILETIME, .T. )
      curl_easy_setopt( hCurl, HB_CURLOPT_NOPROGRESS, 0 )
      curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, .F. )
      curl_easy_setopt( hCurl, HB_CURLOPT_DIRLISTONLY, 1 )
      curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
      curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )

      if ( nResult := curl_easy_perform( hCurl ) ) == 0
         curl_easy_dl_buff_get( hCurl )
      else
         ? "error code:" + Str( nResult )  
      endif
   endif

   curl_global_cleanup()

return nResult == HB_CURLE_OK

 

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 9:20 am
by goosfancito
soy nuevo con todo esto, pasaron años y la verdad que me desactualice.
al probar los ejemplos veo que el include
Code: Select all  Expand view
#ifdef __PLATFORM__WINDOWS
   #include "c:\harbour\contrib\hbcurl\hbcurl.ch"
#else
   #include "/usr/include/harbour/hbcurl.ch"
#endif

no aparece en mi version de hb. como puedo obtenerlas?
gracias

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 9:22 am
by cnavarro
Gustavo, estas lineas son para mod-harbour
Si descargas las versiones de harbour que vienen en la página de fivetech ya viene lo necesario, solo necesitas incluir en tu prg
#include "hbcurl.ch"

Si no estuviera el fichero hbcurl.ch en la carpeta include de harbour, bájate el repositorio de harbour y en las contribs está en su correspondiente carpeta

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 9:35 am
by goosfancito
gracias,
abandone el proyecto. no puedo hacer que funcione el ftp y me sacaron el proyecto.

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 9:47 am
by Antonio Linares
Gustavo,

Este ejemplo esta probado esta misma mañana y funciona correctamente:
https://github.com/FiveTechSoft/mod_harbour/blob/master/samples/ftpup.prg

Animo que lo consigues. No te rindas :-)

Re: FTP: Request to share samples

PostPosted: Fri Apr 30, 2021 11:01 am
by goosfancito
no pasa nada. ya me lo sacaron.

Re: FTP: Request to share samples

PostPosted: Mon May 10, 2021 7:26 pm
by Baxajaun
hmpaquito wrote:thks mr. Enrico

BTW, is it possible obtain PSFTP command result ? success or not success ? how to ?


Paco,

please, review this link https://stackoverflow.com/questions/41725928/putty-psftp-return-codes

Best regards,

Re: FTP: Request to share samples

PostPosted: Tue May 11, 2021 6:02 am
by hmpaquito
Gracias Félix. 0, 1, 2 son los EXIT code detectables con ERRORLEVEL que supongo que se puede coger con GetEnv("ERRORLEVEL")