Operating System - Linux
1748051 Members
5072 Online
108758 Solutions
New Discussion юеВ

Re: Text file to transfer to HPUX via Samba

 
Anthony Villanueva
Frequent Advisor

Text file to transfer to HPUX via Samba

I'm stumped as I cannot find any solution.

Samba in my HPUX is working fine. I am able to copy files between Windows and UNIX(via windows explorer). My problem is that when a text file from windows is saved into the home directory in unix, the text file has the "^M" at the end of each line. I know how to use FTP but my concern is for the common users. Another thing, some users are able to copy the text file to unix without the "^M" character in the unix file. While other users, when they save the text file into Samba, there is a "^M" at the end of each line.

Is there a setting that I'm missing here? Please help!
5 REPLIES 5
Sandman!
Honored Contributor

Re: Text file to transfer to HPUX via Samba

Unfortunately there is no setting or workaround for this. Best bet is to use dos2ux utility for getting rid of those pesky Windows Ctrl-M characters at the end of each line.

# dos2ux infile > outfile
Darren Prior
Honored Contributor

Re: Text file to transfer to HPUX via Samba

There is no setting to change this, as Sandman pointed out. Samba is transferring the file as a byte for byte copy of the original and is unaware of the type of file you are transferring.

If you are using Samba just to store files on the HP-UX server then there would be no need to convert the files as you would be using them on Windows. Can you give details of the way you are using the text files?

regards,

Darren.
Calm down. It's only ones and zeros...
spex
Honored Contributor

Re: Text file to transfer to HPUX via Samba

Anthony,

You're seeing '^M' at the end of each line because of the difference in DOS/Windows and *nix line termination characters. DOS/Windows represents the end of a line by a CR followed by a LF, while *nix OSes use just a LF character. So the DOS/Windows CR character shows up as '^M' under *nix.

If you do need to convert the textfiles (rather than just store them on your HP-UX box), I would suggest automating the conversion process. Create "drop folders" under HP-UX, and schedule conversion scripts via cron.

For example, say you had the following directory structure:

1. /text/dos2ux/in
2. /text/dos2ux/out
3. /text/ux2dos/in
4. /text/ux2dos/out

You could then create/schedule this script for (1) and (2):

#!/usr/bin/sh
for f in $(ls /text/dos2ux/in)
do
dos2ux ${f} &&\
mv ${f} /text/dos2ux/out ||\
mv ${f} /text/dos2ux/failed
done
exit 0

And this script for (3) and (4):

#!/usr/bin/sh
for f in $(ls /text/ux2dos/in)
do
ux2dos ${f} &&\
mv ${f} /text/ux2dos/out ||\
mv ${f} /text/ux2dos/failed
done
exit 0

Set up the appropriate samba shares, and instruct users on their use. Then schedule the scripts to run every minute or so.

PCS
Bill Hassell
Honored Contributor

Re: Text file to transfer to HPUX via Samba

This problem is the first thing that SAMBA users discover about different operating systems, that is, they aren't compatible. SAMBA can work as a NAS device where PC users can store files on the HP-UX box, but as a mechanism to exchange plain ASCII data, you will have to go through the pain of conversion in both directions all the time.

Now if there are binary data files and there are applications that run on both systems that can read these binary files, all is well. Otherwise, ftp is a better choice because it understands how to convert ASCII files between any computer (Macs, mainframes, PCs, etc).


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: Text file to transfer to HPUX via Samba

Shalom,

Newer versions of Samba have allowed me to correct this problem. When I upgraded to a CIFS/9000 version based on Samba 3, this specific issue stopped happening on my Samba servers.

The latest version of the server is available on http://software.hp.com

Search for CIFS/9000

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com