I'm currently evaluating PureBasic and its SFTP feature in particular. I have problems with the code below -- RenameFTPFile fails (as does DeleteFTPFile) every single time. Opening connection, setting remote directory and uploading files works fine. So... am I doing something wrong here or is there an issue with said procedures?
The target machine is an Ubuntu Linux 20.04 while the PB app is running on Win11.
Code: Select all
; Set EXE format to Console in Compiler options
Procedure SFTP_Test()
; Set server, paths and credentials to real values before testing
Protected server$ = "sftp://server.com", usr$ = "user123", pwd$ = "password123"
Protected rmtDir$ = "/home/user/Downloads"
Protected srcFile$ = "c:\temp\image.png", tempFile$ = "_tmp.image.png", destFile$ = "image.png"
If OpenFTP(0, server$, usr$, pwd$, #True, 22)
If SetFTPDirectory(0, rmtDir$)
PrintN("Remote directory is " + GetFTPDirectory(0))
SendFTPFile(0, srcFile$, tempFile$)
If RenameFTPFile(0, tempFile$, destFile$) = 0
PrintN("Error renaming '" + tempFile$ +"'") ;<=== Always fails
EndIf
Else
PrintN("Unable To set remote directory: "+ rmtDir$)
EndIf
CloseFTP(0)
Else
PrintN("Failed to connect to: " + server$)
EndIf
EndProcedure
OpenConsole()
SFTP_Test()
CloseConsole()