FTP: Request to share samples

Re: FTP: Request to share samples

Postby cnavarro » Fri Apr 30, 2021 8:50 am

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

 
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
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: FTP: Request to share samples

Postby goosfancito » Fri Apr 30, 2021 9:20 am

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
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Postby cnavarro » Fri Apr 30, 2021 9:22 am

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
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: FTP: Request to share samples

Postby goosfancito » Fri Apr 30, 2021 9:35 am

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
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Postby Antonio Linares » Fri Apr 30, 2021 9:47 am

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
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FTP: Request to share samples

Postby goosfancito » Fri Apr 30, 2021 11:01 am

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
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: FTP: Request to share samples

Postby Baxajaun » Mon May 10, 2021 7:26 pm

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,
User avatar
Baxajaun
 
Posts: 961
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: FTP: Request to share samples

Postby hmpaquito » Tue May 11, 2021 6:02 am

Gracias Félix. 0, 1, 2 son los EXIT code detectables con ERRORLEVEL que supongo que se puede coger con GetEnv("ERRORLEVEL")
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 90 guests