View Full Version : copy files to samba

04-28-2008, 02:55 AM
My questio is perhaps very fool, but I'm not able to find an answer!!
I 've a server that share a directory with samba.
In my PC I see such directory in ubuntu i.e. smb://server/test.
I need to create a script .sh to copy some files in smb://server/test
So i perform
cp smb://server/test *.txt
but I get an error...
My question is:
How I can copy some files from my local PC to a server samba shared directory by shell commands?

Thanks in advance

04-28-2008, 03:01 AM
cp smb://server/test *.txt

You can't copy to *.txt - what do you actually want to do?


04-28-2008, 03:10 AM
Ok, exchanging the operands the result is the same!
cp *.txt smb://server/test
the command tel me that is impossible to create smb://server/test, but that directory already exists and dragging a file in such directory (graphically) it is ok!

04-28-2008, 06:31 AM
The smb:... directory does not really exist. Not the way the kernel sees it.

You have to distinguish between two file systems here. One is the native Linux file system. It's rooted at / and all its absolute paths are of the form /something/or/other.
The other is your desktop system's virtual file system. In order to transparently support more data sources without having to mount them into the kernel tree, all popular desktop environments (probably Gnome in your case) have a VFS that uses URLs are paths. They map the native kernel tree unto file://... URLs, and then go on and implement additional schemes, like smb://... (SMB or CIFS network file system), fish://... (KDE's ssh/scp-based remote file system), etc.
These VFS URLs work only in programs written for this desktop environment and only if they really use only the DE's file manipulation routines.

Shell utilities such as cp have no ideas what to do with these URLs. They only accept kernel file system paths. This means that if you want to use cp to copy files to a samba share, you have to mount it.

# mount -t cifs //server/test /mnt/test -o user=username