Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Samba: How do I transfer text files as dos2unix/unix2dos?

Status
Not open for further replies.

eeb

Technical User
Sep 12, 2001
12
GB
I have got Samba up and running, and everything is working great. The only issue I have encountered is that when I copy a text file (e.g. a script) from PC across to the UNIX using Windows Explorer, then go to edit the file in UNIX using vi, all the carriage returns have been substituted with ^M. This means that I have to replace them all before I can run the script or whatever. :-(

Any ideas for a ^M free transfer?

Thanks

Emma
 
Hello Emma

I solved the problem with this script, hope it works for you:

#!/usr/bin/ksh
#
for FILENAME in $* ; do
sed 's/$/^M/g' ${FILENAME}
done

I called it ux2dos (like in HP-UX) and the syntax is:
ux2dos file1(with ^M) >> file2(free from ^M)

/F
 
F,

Thank you for that, I will give it a go. It will definitely help getting rid of all those ^Ms. I thought there might be a smb.conf keyword that might carry out a dos2unix automatically. I couldn't see one that might though so thanks for the script.

Emma
 
Strange, I've got a very basic Samba installation & don't have this problem.

I'm by no means a Samba expert, but I've checked in our smb.conf file & can't see any options that would affect this.

It might help you get feedback from someone who knows Samba well if you post the versions involved (Samba, unix & windows).
One by one, the penguins steal my sanity.
 
Good idea, it might be a version thing. I am running Samba 2.0.0 (ready made package which I downloaded from the web) on Solaris 2.6 although will be changing to Solaris 8 soon, and my PC is running Windows 2000.

Any ideas as to how, when I copy files from PC to my samba share using Windows Explorer I can get it to carry out dos2unix automatically will be much appreciated.

Emma
 
May be irrelevant, but I have encountered something like this when transferring files over a Novell network (not using Samba).

Greg.
 
Just remembered, I don't have this problem with ^M in Samba, it's on a PC with NFS-client software that mounts a directory from my Unix server. The PC get the ^M in files from the NFS-mounted dir unless I run them through the script first. I have never seen this problem with Samba.

-Fredrik
 
This is not a problem with samba. there should be no translation on a file just because it's sitting on a *nix machine. The problem is in the creation of the file if it's intended target is for use on a *nix system. If you need translation ftp will do it or running a translation program on the *nix side (dos2unix, unix2dos, xtod, dtox, etc). There are a number of text editors for windows that deal with unix formats ( pfe32, context, ...etc).

my2cents
stan
 
That makes sense. Actually the script I was talking about had been sent to me on email so I don't know the origin of it. I just jumped to the conclusion that it had something to do with samba as I can't remember having that problem with ftp. Jumping to conclusions, sorry!! :)

Thanks

Emma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top