smbclient //server/share -U user -c 'ls'

Category: Local Network & Public Hosting

smbclient //server/share -U user -c 'ls'

Run one SMB command without a shell

The -c flag executes a single command inside the share and exits, which makes smbclient scriptable. Here it lists the share contents, and the same pattern works with get, put, mkdir, or del. Quote the command so the shell passes it whole to smbclient.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.