Page 1 of 3

Directorio y descarga mediante SFTP

Posted: Thu Oct 11, 2018 5:52 pm
by edufloriv
Saludos amigos,

¿ Alguien tiene código fuente para obtener el directorio y descargar archivos mediante SFTP usando key (SSH) ? Ya puedo subir archivos, pero he buscado en la red y no encuentro los comandos para obtener el directorio y descargar.

Agradeceré su ayuda por favor. Mil gracias anticipadas.


Greetings, friends

Does anyone have source code to get the directory and download files using SFTP using key (SSH)? I can upload files, but I searched the network and can not find the commands to obtain the directory and download.

I will appreciate your help please. Many thanks in advance.



Att.

Re: Directorio y descarga mediante SFTP

Posted: Fri Oct 12, 2018 10:34 am
by dragancesu
Windows has a built-in ftp client that is not for serious use

In applications that need to send / receive data via ftp companies we use the program ncftp as an external solution, it is not perfect, but it has everything

there are several programs, one is ncftpls that serves to output the contents of a folder, then it is easy to redirect it to a file, this is our solution

Try

https://www.ncftp.com/ncftp/

or

https://winscp.net/eng/docs/commandline

Re: Directorio y descarga mediante SFTP

Posted: Mon Oct 15, 2018 8:27 pm
by edufloriv
Thank you very much, I will try both, thanks for your answer.

Muchas gracias, probaré ambos, gracias por tu respuesta.


Att.

Re: Directorio y descarga mediante SFTP

Posted: Thu Oct 25, 2018 12:02 pm
by edk
edufloriv wrote:
Thu Oct 11, 2018 5:52 pm
Greetings, friends

Does anyone have source code to get the directory and download files using SFTP using key (SSH)? I can upload files, but I searched the network and can not find the commands to obtain the directory and download.

I will appreciate your help please. Many thanks in advance.
Hola Eduardo Flores.

Check out this sample simple application to navigate on an SFTP server.
It only supports basic functions:
- listing of folders / files of local disks and a remote host
- navigating local and remote folders
- copying files (one at a time) from a local disk to a remote folder (upload)
- copying files (one at a time) from a remote folder to a local drive (download)
- renaming files / folders on local disks and on a remote host
- creating folders on local disks and on a remote host
- deleting files and folders from local drives and from a remote host

I tested with a local SFTP server (Bitvise SSH Server 7.46) and with a demo public sftp server: sftp://demo.wftpserver.com/
Authorization with a username and password. I can not authorize using a Public / Private key pair (maybe I have generated it incorrectly or I can not configure it properly, I have no experience with this).

Cheers.
SFTP_Navigator.png
SFTP_Navigator.png (45.31 KiB) Viewed 1471 times
SFTP_Navigator.7z
(1.23 MiB) Downloaded 137 times

Re: Directorio y descarga mediante SFTP

Posted: Fri Oct 26, 2018 9:34 am
by edk
Small improvements:
- when changing the folder to the parent, the active row is set to the name of the folder that you left.
- when adding a new folder, the active row is set on the created folder
- when deleting a file or folder, the active row remains in the nearest position of the deleted item.
- go to the parent folder with the BACKSPACE key.
sftp.7z
(6.63 KiB) Downloaded 65 times

Re: Directorio y descarga mediante SFTP

Posted: Fri Oct 26, 2018 11:42 am
by vientopamperosur
Buenas compañeros, estoy interesado en probar este ejemplo, pero no puedo compilarlo para estudiarlo, me falta hbcurl.ch, Donde puedo conseguir este archivo?

Re: Directorio y descarga mediante SFTP

Posted: Fri Oct 26, 2018 3:53 pm
by edk
To properly compile you should have the HMG 3.4.4 version installed
Then, from this package: http://hmgforum.com/download/file.php?id=8685 copy all files from the "lib" folder to "c:\hmg.3.4.4\HARBOUR\lib\win\mingw"

You compile by running "build_SFTP.bat" (we compile sftp.hbp not sftp.prg)

The hbcurl.ch file should be in "c:\hmg.3.4.4\HARBOUR\contrib\hbcurl\"

Re: Directorio y descarga mediante SFTP

Posted: Sun Oct 28, 2018 12:14 pm
by PeteWG
edk wrote:
Fri Oct 26, 2018 9:34 am
Small improvements:
- when changing the folder to the parent, the active row is set to the name of the folder that you left.
- when adding a new folder, the active row is set on the created folder
- when deleting a file or folder, the active row remains in the nearest position of the deleted item.
- go to the parent folder with the BACKSPACE key.
sftp.7z
excellent sample! 8-)
thanks for sharing

regards,
Pete

Re: Directorio y descarga mediante SFTP

Posted: Mon Oct 29, 2018 10:33 am
by vientopamperosur
Muchas gracias, voy a probarlo!

Re: Directorio y descarga mediante SFTP

Posted: Mon Oct 29, 2018 10:42 am
by vientopamperosur
Buen día. Sigo teniendo problemas...

Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x3d8): undefined reference to `HB_FUN_CURL_EASY_INIT'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x3f8): undefined reference to `HB_FUN_CURL_EASY_RESET'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x418): undefined reference to `HB_FUN_CURL_EASY_PERFORM'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x438): undefined reference to `HB_FUN_CURL_EASY_STRERROR'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x488): undefined reference to `HB_FUN_CURL_GLOBAL_CLEANUP'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x498): undefined reference to `HB_FUN_CURL_EASY_ESCAPE'
C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o:sftp.c:(.data+0x4a8): undefined reference to `HB_FUN_CURL_EASY_SETOPT'
collect2.exe: error: ld returned 1 exit status
hbmk2[sftp]: Error: Ejecutando enlazador. 1
gcc.exe C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/sftp.o C:/Users/ale/AppData/Local/Temp/hbmk_zigy1s.dir/hbmk_3nzs0n.o C:/HMGSQL/Ejemplos/sftp/SFTP_Navigator/_temp.o -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbmysql -lmysql -lhbfimage -lhbpgsql -lsddmy -lhbvpdf -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbtip -lsqlite3 -lhbsqlit3 -lsddodbc -lrddsql -lhbodbc -lodbc32 -lhbhpdf -lhbnetio -lxhb -lpng -llibhpdf -lhbzebra -lhbextern -lhbdebug -lhbvmmt -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -o"SFTP Navigator.exe" -Lc:/hmg.3.4.4/harbour/lib/win/mingw -Lc:/hmg.3.4.4/lib

hbmk2: Sugerencia: A¤ade la opci¢n 'hbcurl.hbc' para las funciones que faltan:
curl_easy_setopt(), curl_easy_escape(), curl_global_cleanup(),
curl_easy_strerror(), curl_easy_perform(), curl_easy_reset(),
curl_easy_init()

he hecho todo lo indicado y me aparece este texto en build.log. Que estoy haciendo mal???