Skip to content

Reads 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.

Functions

  • newSession SambaSession Creates a session for one share (for example "reports" in \\fileserver\reports).
  • close self Closes every Samba session created with Samba.newSession in this script.
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

hostname string
Host name or IP address of the file server
username string
User name to log in with
password string
Password; use secret()
shareName string
Name of the share, without the server or slashes

Returns

SambaSession One Samba/SMB share.

Example

local share = Samba.newSession("fileserver.example.com", "reports-bot", secret("samba_password"), "reports")
share.copyRemoteToLocal("2025/summary.xlsx", "input/summary.xlsx")
share.close()
Samba.close()→self

Closes every Samba session created with Samba.newSession in this script.

Returns

self chainable The library itself, so calls can be chained.