# SAMBA: Apostrophe in file name results cp: cannot stat....

## cfuser

Basically, I have a W2K share mounted via the following command in my fstab

//nt/mp3      /mnt/nt/mp3   smbfs   username=dude,password=blahblah,fmask=0777,rw,codepage=cp437    0 0

When I attempt to copy a file from this share, I receive the error

cp: cannot stat `/mnt/nt/mp3/Dido/Life For Rent/Dido - Don\'t Leave Home.mp3': No such file or directory

(notice the apostrophe)

Referencing:

https://forums.gentoo.org/viewtopic.php?t=105988&highlight=samba+filename&sid=8f0673b44bf4046ddaca81aaf0488bea

I have tried adding the parameter "codepage=cp437" to my fstab (as above) and the client code page = 437 to my smb.conf but that didn't seem to help.  (the codepage on my w2k box is 437, btw)

Every other file copies over fine, just the one's w/ odd names don't seem to play nice.

Probably something simple and rehashed, but I'm not really finding an answer on my searches (or posts to linux.samba).

Any ideas or references? 

TIA.

----------

## sak102010

Can you show us what the 'cp' command that you're using to copy the file looks like?

----------

## jftuga

I have noticed the same problem when copying files from windows to linux, but have not found a solution.  I, too, would be interested in how to fix this.

-John

----------

## sak102010

Maybe I misread something, but are you guys saying that this only happens with a smb share?  If you have a file of the same name in you linux filesystem you can copy it around all day long, but not if it's in a smb share?

----------

## cfuser

 *Quote:*   

> Can you show us what the 'cp' command that you're using to copy the file looks like?

 

Sure...

```
cp -r /mnt/nt/mp3/Dido/* .
```

----------

## sak102010

Do you get the same error if you actually descend into the directory and copy the problematic file by itself?

----------

## cfuser

Same error w/ an explict file name (note in this case I used bash completion to fill out the name, hence the escape chars)

```
cp /mnt/nt/mp3/Dido/Life\ For\ Rent/Dido\ -\ Don\'t\ Leave\ Home.mp3  .

cp: cannot stat `/mnt/nt/mp3/Dido/Life For Rent/Dido - Don\'t Leave Home.mp3': No such file or directory

```

I touched a file called "c's file".  Using Konqueor, I can copy it just dandy (BTW, Konqueror complains about the apostrophe when I try to go from the samba share to a local file)  Using bash, all I can (or know how to do, actually) is

```
cp  "c's file" /tmp
```

which works fine.  (Bash completion doesn't seem to want to work after I include the apostrophe.  How would you do this from the command line?)  

So, to answer the question, yes, it seems apostophed files can be copied fine (from Konqeuor, at least).

Also, any other odd characters (Many titles of Clannad MP3s, for instance) also cause complaints.

----------

## cfuser

Let me at least ask this--have other people experience the same issue or is there simply something misconfigured on my systems...not too much of a show stopper (there are other ways to transfer files), but pretty annoying...any insight or commiseration would be appreciated.  TIA.

----------

## nobspangle

I tested this out, I don't have a Win2K server only 2k3 but the effect should be the same. First off I mounted a share on the server from gentoo using

```
mount -t smbfs -o username=username //server/share /mount/point
```

Once that was mounted I tried copying a file called "help'me out.txt" from the share onto the gentoo server. This worked fine.

I also tried creating a file called "help'you out.txt" on the gentoo box and copying that onto the share. This also worked fine.

Since we are using the smbfs file system this has nothing to do with samba configuration, so I'm afraid I can offer you very little help apart from telling you that it works for me and I'm using a vanilla 2.6.4 kernel. When copying the files I used cp with the spaces and apostrophes escaped using \

----------

## etnoy

I have that problem, on a 2.6.8.1 and on a 2.6.9 machine  :Sad: 

Somebody, advice?

----------

## etnoy

I think I solved the problem.

The windows macine from which the shares were mounted had a few files which had strange filenames. These files didn't display correctly even on the windows machine.

I will delete the affected files and resume operation.  :Smile: 

----------

## jonnevers

heres another angle:

if you are using a mounted samba share... why not use nautilus/konqueror (or some other filesystem browser) to move the files using cntrl-C and then cntrl-V ?

----------

## etnoy

 *jonnevers wrote:*   

> heres another angle:
> 
> if you are using a mounted samba share... why not use nautilus/konqueror (or some other filesystem browser) to move the files using cntrl-C and then cntrl-V ?

 

Difficult when it is a remote fileserver, no X at all.

----------

