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

Ask about the individual Gambas components here.
Post Reply
kse
Posts: 1
Joined: Thursday 14th February 2019 2:23pm

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

Post 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
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

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

Post by stevedee »

User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

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

Post 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
shordi
Posts: 8
Joined: Thursday 7th March 2019 6:04pm

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

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