Directorio y descarga mediante SFTP

HMG en Español

Moderator: Rathinagiri

User avatar
edufloriv
Posts: 139
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB
Location: PERU
Has thanked: 1 time
Been thanked: 4 times

Directorio y descarga mediante SFTP

Post by edufloriv » Thu Oct 11, 2018 5:52 pm

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: 581
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 16 times
Been thanked: 111 times

Post by dragancesu » Fri Oct 12, 2018 10:34 am

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: 139
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB
Location: PERU
Has thanked: 1 time
Been thanked: 4 times

Post by edufloriv » Mon Oct 15, 2018 8:27 pm

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: 385
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 114 times
Been thanked: 285 times

Post by edk » Thu Oct 25, 2018 12:02 pm

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 725 times
SFTP_Navigator.7z
(1.23 MiB) Downloaded 76 times

edk
Posts: 385
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 114 times
Been thanked: 285 times

Post by edk » 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
(6.63 KiB) Downloaded 41 times

User avatar
vientopamperosur
Posts: 37
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Has thanked: 1 time
Contact:

Post by vientopamperosur » Fri Oct 26, 2018 11:42 am

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: 385
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 114 times
Been thanked: 285 times

Post by edk » Fri Oct 26, 2018 3:53 pm

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: 126
Joined: Sun Mar 21, 2010 5:45 pm
Has thanked: 6 times
Been thanked: 36 times

Post by PeteWG » Sun Oct 28, 2018 12:14 pm

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: 37
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Has thanked: 1 time
Contact:

Post by vientopamperosur » Mon Oct 29, 2018 10:33 am

Muchas gracias, voy a probarlo!

User avatar
vientopamperosur
Posts: 37
Joined: Thu Aug 28, 2014 10:13 am
DBs Used: DBF, SQLite, MySQL, MariaDB, PostgreSQL
Location: Buenos Aires
Has thanked: 1 time
Contact:

Post by vientopamperosur » Mon Oct 29, 2018 10:42 am

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