In past OSX versions, one could copy files from SMB shares like so:
smbclient //my-server/foo -U USER%PASS -I 127.0.0.1 -c "get my.file"
However, in recent versions, sbmclient has been replaced with smbutil which does not have copying capabilities. As far as I can tell, the only replacement is mount -t smbfs. I am not aware of any way to install smbclient on OSX (Print file from terminal via smb).
Mounting is pretty annoying though:
- You have to create a folder for the mount point (what if it already exists?)
- If the same folder has already been mounted on a different folder,
mountwill fail (with a pretty misleading error) - There's no "structured" way to tell which shares are mounted where (that I know of), meaning you'll have to
grep/sedthe output ofdfto try and work around the issues above
Basically I just want to reliably copy a file from an SMB share in a bash script, and the issues above make it more complicated than it should be (and already was before smbclient was dropped).
$ cp chat.db smb://NAS6ABA8C._smb._tcp.local/iPhone-SMS-backup/chat-DB-backup/ cp: directory smb://NAS6ABA8C._smb._tcp.local/iPhone-SMS-backup/chat-DB-backup does not exist
Do I still have to go through the whole
– Raleigh L. Oct 03 '22 at 05:28smbfsrigamarole just to be able to simply copy the file to the remote location?