Sample Script: TLuaSFTPClient
--Demonstrates the Lua SFTP client class
--Create the client device
sftp = TLuaSFTPClient()
--Connect to the remote SFTP server
if sftp:Connect("username","password") == false then
SetExitStatus("No respons",false)
return
end
--Create a directory handle and open the current directory
hHandle = TLuaSFTPClientDirectoryHandle()
bOk = sftp:OpenDir(".",hHandle)
if bOk == true then
-- List the directory
bOk = sftp:ListDir(hHandle)
if bOk == false then
SetExitStatus("Cannot list directory",false)
sftp:CloseDir(hHandle)
return
end
--Loop over the entries in the directory
File = TLuaSFTPClientFile()
while hHandle:Next(File) ~= false do
--Print the file name
print(File.m_sFilename)
end
end
--Close handle
sftp:CloseDir(hHandle)