Samba
libraryReads and writes files on Windows/Samba shares (SMB 2 and 3; servers that only offer SMB 1 do not work). Samba.newSession returns an SambaSession for one share. Things to know: there is no persistent connection. Every operation connects, logs in, does its work and disconnects again, so errors (unreachable host, wrong password, unknown share) appear at the first operation, not in newSession. There is no domain, port or timeout setting. Use secret() for the password.
- Kind Library, a global in every script
- Category Remote & Infrastructure
- Functions 2
Objects
Functions
-
newSessionSambaSession Creates a session for one share (for example "reports" in \\fileserver\reports). -
closeself Closes every Samba session created with Samba.newSession in this script.
newSession()
Section titled “newSession()”Samba.newSession(hostname: string, username: string, password: string, shareName: string)→SambaSession Creates a session for one share (for example "reports" in \\fileserver\reports). Only stores the settings; it does not connect. The user name is sent with an empty domain.
Parameters
-
hostnamestring - Host name or IP address of the file server
-
usernamestring - User name to log in with
-
passwordstring - Password; use secret()
-
shareNamestring - Name of the share, without the server or slashes
Returns
Example
local share = Samba.newSession("fileserver.example.com", "reports-bot", secret("samba_password"), "reports")share.copyRemoteToLocal("2025/summary.xlsx", "input/summary.xlsx")share.close()close()
Section titled “close()”Samba.close()→self Closes every Samba session created with Samba.newSession in this script.
Returns