1833433 Members
2819 Online
110052 Solutions
New Discussion

dos2ux command tool

 
Pando
Regular Advisor

dos2ux command tool

I have a bulk of files to be transfer to my HP-UX from my MS Windows environment to HP-UX. I have use CIFS client to mount my Windows NT/2003 shared to my HP-UX. From that point, I used the mv command to transfer data to my HP-UX. When i use the vi command. I saw ^M character at the end of each line. I know dos2ux will do the trick but i have a bulk of files to be transfer/move to my HP-UX for compression and transfer of files to my clients. Is there a way to eliminate the insertion of ^M character during transfer or how will i use the dos2ux tool to remove the ^M automatically?
7 REPLIES 7
curt larson_1
Honored Contributor

Re: dos2ux command tool

instead of moving the file:
mv wfile ufile
use dos2ux
dos2ux < wfile > ufile
Joseph Loo
Honored Contributor

Re: dos2ux command tool

hi,

i believe u have come to a dead end if u want to remove ^M automatically using dos2ux via copying the file from the share path:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=30923

i too get this problem. with ftp, i have to indicate ascii transfer mode so as not to get ^M in my files. if u choose auto transfer mode, ^M will still appear.

regards.
what you do not see does not mean you should not believe
Hemanth Gurunath Basrur
Honored Contributor

Re: dos2ux command tool

Hi,

As Joseph has mentioned, you will have to use the bin command before you start the process of copying files from Windows to HP-UX.

Also, refer to the foll. link:

http://www.karkomaonline.com/article.php?story=20031115012117477

Regards,
Hemanth
Alexander M. Ermes
Honored Contributor

Re: dos2ux command tool

Hi there.
Just my 2 cts.
On FTP transfer of ASCII files you have to tell the ftp, that you want to transfer an ASCII file.
Looks like this :

ftp> ascii
200 Type set to A. ( should be the reply )

for binary files ( executables / zipped files etc ) use this :

ftp> bin
200 Type set to I. ( should be the reply )

On ASCII transfer from Windows to Unix the ^M ( CR / LF ) will be scratched on the unix file.

This will also add the ^M on a transfer from Unix to Windows.

by the way :

ftp> ? (shows all available ftp-commands )

Hope i could help.
Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Elmar P. Kolkman
Honored Contributor

Re: dos2ux command tool

A way to check if your files are DOS ASCII files:

awk '/\r$/ { rec++}
END {if (NR-1 == rec) { print "DOS FILE" }}'

This way you know which files need to be put through dos2ux and which not.

So in your case, if you put the awk command in a script called chkdos, you can convert all DOS ascii file using this shell command:

find . -type f -print | while read fname
do
if [ "$(chkdos <$fname)" -eq "DOS FILE" ]
then
dos2ux <$fname >/tmp/tmpf
cp /tmp/tmpf $fname
fi
done
Every problem has at least one solution. Only some solutions are harder to find.
Kyri Pilavakis
Frequent Advisor

Re: dos2ux command tool

If it's a one off, then do as others have suggested. I do a lot of file transfers from unix to windows and I either use QVT/FTP or Reflection for Unix and Digital. Both just like using Windows Explore.
Bosses don't undestand..HP does
Raymond Phillips
New Member

Re: dos2ux command tool

Perhaps this technique would be convenient for you.

- put the file(s) (and directory(ies)) you want to move from the Windows
machine into a .zip file, say dosfiles.zip
- ftp dosfiles.zip file to the unix machine using binary mode
- on the unix machine use info-zip's unzip [1] command with the -a option to
extract dosfiles.zip's contents. unzip's man page says:

"The -a option causes files identified by zip as text files (those with the `t'
label in zipinfo listings, rather than `b') to be automatically extracted
as such, converting line endings, end-of-file characters and the character
set itself as necessary."


[1] http://www.info-zip.org/UnZip.htm