SFTP in Network coding with gb.net.curl not possible

Post

Posted
Rating:
#1 (In Topic #225)
kse
Trainee
 I try to setup processes in Gambas to connect to an external SFTP Server using the FTPClient of Curl. But he does not understand "SFTP" as a connection methode.
Is there somewhere an example with SOCKET or similar to connect and read out data from a romete SFTP Server ? - Working on UBUNTU 18.04, Gambas 3.11.
Peter
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Maybe this helps:-

sftp wie? - Der Gambas Club
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi kse and welcome to the forum.

Matt and I have taken the code from stevedee's example and altered it a little. It worked for us!

Make sure you change the values of sHost, sRemoteFile, sOutputFile and sPassword

Code (gambas)

  1. Private $SFTPClient As Process
  2.  
  3. Public Sub Form_Open()
  4. Dim sCommand As String[]
  5. Dim sCopy, sHost, sRemoteFile, sOutputFile As String
  6.  
  7. sCopy = "scp"
  8. sHost = "root@8:8:8:8:"  'Pay attention to the "colon" at the end!
  9. sRemoteFile = "/home/test.txt"
  10. sOutputFile = User.Home
  11.  
  12. sCommand = [sCopy, sHost & sRemoteFile, sOutputFile]
  13. $SFTPClient = Exec sCommand For Input Output As "sftpProcess"
  14.  
  15.  
  16. Public Sub sftpProcess_Read()
  17. Dim sBuffer As String
  18. Dim sPassword As String = "YourPassword"
  19.  
  20. Read #$SFTPClient, sBuffer, Lof($SFTPClient)
  21.  
  22. If InStr(sBuffer, "password:") Then 'When prompted for the password, then
  23.   Print #$SFTPClient, sPassword 'Insert the password
  24.  
  25. If InStr(sBuffer, "100%") Then Print "Done"
  26.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
I have a gambas application running based in ftpclient component. We use ftp and we are thinking about change to sftp…
I don't like the title of this post!  :lol:  :lol:  :lol:
But if someone has the way to use ftpclient of gb.net.curl on sftp I'm very interested on it.
Thanks in advance
Online now: No Back to the top
1 guest and 0 members have just viewed this.