Directorio y descarga mediante SFTP

HMG en Español

Moderator: Rathinagiri

User avatar
edufloriv
Posts: 238
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
Location: PERU

Directorio y descarga mediante SFTP

Post 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.

Eduardo Flores Rivas


LIMA - PERU
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Directorio y descarga mediante SFTP

Post 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
Last edited by dragancesu on Mon Oct 15, 2018 8:28 pm, edited 1 time in total.
User avatar
edufloriv
Posts: 238
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB, MySQL, MSSQL, MariaDB
Location: PERU

Re: Directorio y descarga mediante SFTP

Post by edufloriv »

Thank you very much, I will try both, thanks for your answer.

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


Att.

Eduardo Flores Rivas


LIMA - PERU
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Directorio y descarga mediante SFTP

Post 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 4597 times
SFTP_Navigator.7z
(1.23 MiB) Downloaded 375 times
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Directorio y descarga mediante SFTP

Post 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 227 times
User avatar
vientopamperosur
Posts: 59
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Contact:

Re: Directorio y descarga mediante SFTP

Post 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?
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Directorio y descarga mediante SFTP

Post 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\"
PeteWG
Posts: 176
Joined: Sun Mar 21, 2010 5:45 pm

Re: Directorio y descarga mediante SFTP

Post 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
User avatar
vientopamperosur
Posts: 59
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Contact:

Re: Directorio y descarga mediante SFTP

Post by vientopamperosur »

Muchas gracias, voy a probarlo!
User avatar
vientopamperosur
Posts: 59
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Contact:

Re: Directorio y descarga mediante SFTP

Post 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???
Post Reply