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,
mount
will 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
/sed
the output ofdf
to 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).