1753857 Members
7525 Online
108809 Solutions
New Discussion юеВ

dos2unix path

 
Gemini_2
Regular Advisor

dos2unix path

When I run dos2unix like this

dos2unix file

i have no problem, but if I use full path

dos2unix /dir/dir/file

it complains.


does anyone know if there is a workaround?


thank you
10 REPLIES 10
Patrick Wallek
Honored Contributor

Re: dos2unix path

>>i have no problem, but if I use full path
>>
>>dos2unix /dir/dir/file
>>
>>it complains.


What does it complain about? Permissions? Can't find the file? What?

>>does anyone know if there is a workaround?

Not without knowing what it is complaining about.

Please provide any messages it is generating.
Gemini_2
Regular Advisor

Re: dos2unix path

this is an example

[yanga@prince src]$ dos2unix ui/test.txt
dos2unix: converting file ui/test.txt to UNIX format ...
[yanga@prince src]$ dos2unix /users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text
dos2unix: converting file /users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text to UNIX format ...
dos2unix: problems renaming '/users/misc/yanga/T124/BCVOB/TSG/src/ui/d2utmpe5Smg0 ' to '/users/misc/yanga/T124/BCVO
B/TSG/src/ui/test.text'
output file remains in '/users/misc/yanga/T124/BCVOB/TSG/src/ui/d2utmpe5Smg0 '
dos2unix: problems converting file /users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text
Patrick Wallek
Honored Contributor

Re: dos2unix path

What platform is this? Is this HP-UX? If so, is this a non-standard program. The usual command in HP-UX is dos2ux.

Anyway, the key appears to be:

[yanga@prince src]$ dos2unix /users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text
dos2unix: converting file /users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text to UNIX format ...
dos2unix: problems renaming '/users/misc/yanga/T124/BCVOB/TSG/src/ui/d2utmpe5Smg0 ' to '/users/misc/yanga/T124/BCVOB/TSG/src/ui/test.text'

If I am reading this correctly it is trying to overwrite the original file with the converted file. Correct? If so, you may not have the appropriate permission to do that.
Gemini_2
Regular Advisor

Re: dos2unix path

it is linux. but, dos2unix should work very similar right.

I gave two examples there. If I convert it from the directory itself, it is fine. but, if I convert it from the parent directory, it has problem.

Hein van den Heuvel
Honored Contributor

Re: dos2unix path


It should work similar, but the one you use appears to be simply broken. It suffers a buffer overflow problem. Unbelievable, and inexcusable, but the signs are there.

Complain to the provider of the program or switch over to HPUX.

If you do investigate further, then be sure to provide EXACT version information.

This is NOT a generic usage problem.

What Linux? Platform? where does the dos2unix come from.

Good luck!
Hein.



Hein van den Heuvel
Honored Contributor

Re: dos2unix path

>> does anyone know if there is a workaround?

You found it yourself...

(cd $target_direcory; dos2unix $target_file)


The problem was in renaming temporary output file back over the original.

If this was my problem would try with an artifically long directory in the path. See if that works.

# mkdir abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
# cp test/test.txt abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
# dos2unix abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/test.txt

fwiw,
Hein
Gemini_2
Regular Advisor

Re: dos2unix path

yes, that is what I ended up doing it.

I was hoping that there is an easy workaround...well, it is easy enough..

thanks everyone.
James R. Ferguson
Acclaimed Contributor

Re: dos2unix path

Hi:

> it is linux. but, dos2unix should work very similar right.

Well, "similar" != "same". That said, one workaround is to use Perl:

# perl -pe 's%\r\n%\n%; s%\032%% if eof' file

...to update inplace and preserve a copy of the old file as 'file.old':

# perl -pi.old -e 's%\r\n%\n%; s%\032%% if eof' file

Regards!

...JRF...
Patrick Wallek
Honored Contributor

Re: dos2unix path

Since this is an HP-UX forum, most people will almost always assume that the question relates to HP-UX.

IF it does not, then you should state UP FRONT that is an OS other than HP-UX.

Also, there is a LINUX forum that this should really have been posted in.

The dos2ux in HP-UX behaves differently that what you are seeing. The may do equivalent functions, but the do not work the exact same way. The kind of assumption you make could be dangerous with other commands.