Thread: copy files to samba

  1. #1
    Registered User
    Join Date
    Jan 2008

    copy files to samba

    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

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    cp smb://server/test *.txt
    You can't copy to *.txt - what do you actually want to do?

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2008
    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!

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    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
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. fopen vs. _open (for BIG image files)
    By reversaflex in forum C Programming
    Replies: 3
    Last Post: 04-01-2007, 12:52 AM
  4. Copy files
    By ErikDN in forum C Programming
    Replies: 1
    Last Post: 10-09-2004, 07:50 PM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM