Page 1 of 1

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

Posted: Thursday 14th February 2019 2:30pm
by kse
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

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

Posted: Friday 15th February 2019 5:05pm
by stevedee

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

Posted: Saturday 16th February 2019 3:23pm
by cogier
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
Private $SFTPClient As Process
 
Public Sub Form_Open()
Dim sCommand As String[]
Dim sCopy, sHost, sRemoteFile, sOutputFile As String

sCopy = "scp"
sHost = "root@8:8:8:8:"  'Pay attention to the "colon" at the end!
sRemoteFile = "/home/test.txt"
sOutputFile = User.Home

sCommand = [sCopy, sHost & sRemoteFile, sOutputFile]
$SFTPClient = Exec sCommand For Input Output As "sftpProcess"

End
 
Public Sub sftpProcess_Read()
Dim sBuffer As String
Dim sPassword As String = "YourPassword"

Read #$SFTPClient, sBuffer, Lof($SFTPClient)

If InStr(sBuffer, "password:") Then 'When prompted for the password, then
  Print #$SFTPClient, sPassword 'Insert the password
Endif

If InStr(sBuffer, "100%") Then Print "Done"

End

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

Posted: Thursday 7th March 2019 6:39pm
by shordi
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