FTP: Request to share samples

User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: FTP: Request to share samples

Post by cnavarro »

Antonio
remove this lines for only return list of files

Code: Select all | Expand


      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


curl_easy_setopt( hCurl, HB_CURLOPT_DIRLISTONLY, 1 )
 


and for SFTP, it's neccesary

Code: Select all | Expand


curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
 


and, this is important also

Code: Select all | Expand


curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
 


Full sample for directory files and conexion to SFTP

Code: Select all | Expand


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

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
goosfancito
Posts: 1955
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Post 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

#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
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: FTP: Request to share samples

Post 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
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
goosfancito
Posts: 1955
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Post by goosfancito »

gracias,
abandone el proyecto. no puedo hacer que funcione el ftp y me sacaron el proyecto.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
Antonio Linares
Site Admin
Posts: 42537
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 77 times
Contact:

Re: FTP: Request to share samples

Post 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 :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
goosfancito
Posts: 1955
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Post by goosfancito »

no pasa nada. ya me lo sacaron.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
Baxajaun
Posts: 969
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: FTP: Request to share samples

Post 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,
hmpaquito
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FTP: Request to share samples

Post by hmpaquito »

Gracias Félix. 0, 1, 2 son los EXIT code detectables con ERRORLEVEL que supongo que se puede coger con GetEnv("ERRORLEVEL")
Post Reply