Lo he probado con PSFTP y funciona con los parametros.
Gracias.
Lo he probado con PSFTP y funciona con los parametros.
Gracias.
Yo no lo he probado pero el máster Navarro puso un ejemplo aqui: https://groups.google.com/g/harbour-use ... JY7zJoAQAJ
Añadele los parámetros que no tienes o mejor, coge el ejemplo de D. Cristóbal y ponle tus parámetros de autenticacion.
Ya nos contarás
Gracias, lo volveré a probar a ver si me he puesto mal algún parametro.
No funciona.
Por favor muestra el fuente, la parte del envio, tergiversando claves y direcciones electronicas
Hola compañeros
Alguien pudo conectarse? usando el código propuesto genera un error "protocolo no soportado". Alguien pudo hacerlo funcionar?
Saludos
Te aseguro que funciona de lujo
De hecho, los usuarios de FivEdit, lo sabrán ya que tiene la posibilidad de conectar a servidores SFTP y editar incluso directamente los ficheros alojados en dichos servidores, y, en breve a GitHub también.
Cristobal,
Por favor puedes poner un ejemplo funcional, incluida la dll que usas.
Saludos
Este es el ejemplo que publiqué, lee mi post hasta el final porque si no es posible que obtengas algún mensaje parecido a "protocolo no soportado"
https://groups.google.com/g/harbour-use ... JY7zJoAQAJ
Las DLLs que uso ( hay algunas que no te hacen falta , te pongo el enlace a las que necesita FivEdit para funcionar )
#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/prueba.txt", hb_GetEnv( "c:\prg" ) + "\prueba2.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
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 ) )
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. )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
curl_easy_dl_buff_get( hCurl )
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/prueba.txt", hb_GetEnv( "c:\prg" ) + "\prueba2.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
//curl_easy_setopt( hCurl, HB_CURLOPT_UPLOAD ) // Es un download, no?
//curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
//curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) ) // Qué valor devuelve hb_vfSize( cFileName ) ?
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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OKHola,
Si, es un donwload. Con ese codigo tampoco funciona, de hecho se ejecuta el programa y no hace nada, no da ningún mensaje. Si quieres te mando el codigo completo con todos los datos, más que nada para que lo intente un experto.
Gracias
Acabo de hacerlo funcionar con UPLOAD. El problema era que no accede al subdirectorio dentro del SFTP que se le indica, digamos que accede a sftp://000.000.000.000 , pero no a sftp://000.000.000.000/files.
Alguna indicacion que me pueda ayudar.
Gracias.
#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/PRUEBAS/prueba.txt", "c:\prueba\prueba.txt" )
//? FtpDonwLoadFile( "sftp://000.000.000.000/files/PRUEBAS/prueba.txt", "c:\prueba\prueba.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP)
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
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 ) )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "USUARIO:CONTRASEÑA" )
//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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
//? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK
function FtpDoNwLoadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "USUARIO:CONTRASEÑA" )
curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) ) // Qué valor devuelve hb_vfSize( cFileName ) ?
curl_easy_setopt( hCurl, HB_CURLOPT_DOWNLOAD )
//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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK