1.

Solve : How to use TYPE command?

Answer»

I have a problem where php files have the wrong linefeed after uploading them via ftp. I'm looking for a way to do a batch convert on a nmber of files to fix this problem. I found this article http://en.wikipedia.org/wiki/Newline#Conversion_utilities that says that can be done by typing in Code: [Select]TYPE unix_file | FIND "" /V > dos_file
I tried that but it didn't work. I then tried variations and ended up with Code: [Select]TYPE dos_file
and that still doesn't work.

I'm doing this from a cmd prompt in XP. When I press enter, the line is just displayed again - no output of any kind. I am using the full path for the file. Would somone please point out what I am doing wrong or how to properly run such a command?have you tried:

Code: [Select]type unixfile.txt > dosfile.txt
just without FIND command?Thanks for the reply. I see what I was doing wrong. I only listed the output file in the command. I've changed that now and added back in the original command to edit the file. It does create the new file and the conversion to dos has been done but the file gets truncated. The original file is over 1,000 line but the new file is only 60 lines. Those 60 lines match the original so it is at least reading it correctly, up to a point. These are php files, if that matters. Does anyone know why this may be failing?Quote from: alter on March 23, 2009, 12:04:18 PM

I have a problem where php files have the wrong linefeed after uploading them via ftp. I'm looking for a way to do a batch convert on a nmber of files to fix this problem. I found this article http://en.wikipedia.org/wiki/Newline#Conversion_utilities that says that can be done by typing in Code: [Select]TYPE unix_file | FIND "" /V > dos_file

that's code is working fine here. i tested out this .php file i obtain from net. when viewed in notepad, the line break show as SOMETHING like rectangle character. (ascii 10). after running the command type|find, the line break is properly fixed as ascii13+ascii10

character 13 is carriage return, character 10 is line feed.

DOS uses crlf, Unix uses lf, and mac uses cr.

An alternative method could be to upload the files using binary mode rather then text.Quote from: Reno on March 23, 2009, 11:16:07 PM
that's code is working fine here. i tested out this .php file i obtain from net. when viewed in notepad, the line break show as something like rectangle character. (ascii 10). after running the command type|find, the line break is properly fixed as ascii13+ascii10

I tried debug filename.php -d, using the full path for the filename. Right after pressing enter, it days file can't be found and then hangs. A ctrl z won't end it. Quote from: BC_Programmer on March 23, 2009, 11:34:34 PM
character 13 is carriage return, character 10 is line feed.

DOS uses crlf, Unix uses lf, and mac uses cr.

An alternative method could be to upload the files using binary mode rather then text.
I've been fighting this problem for over a year. Others have suggested forcing the upload in ascii as well as binary. I've tried both ways but it dosn't make a difference. The problem is that sometimes I may have forty files with this problem mixed in with other files that are fine and of different types. So forcing an upload, even if that worked, would require more work than fixing each file manually and then uploading normally. I tried using sed to do it but can't get that to work either (nor could the sed groups I asked in). Then I ran across this command and thought my problems were solved. But I'm beginning to think this is a problem without a solution.This is one solution:http://download.cnet.com/Unix2DOS/3000-2381_4-10488164.html
Thanks for the link. I wasn't AWARE of that program. It won't help since it only handles one file at a time but I did find one with the same name that says it runs in batch mode but it doesn't work as described. But that gives me something to search for. If two of these exists, there are PROBABLY others so I will keep looking. Thanks for all of the help. It did make a difference and I appreciate it.
Sometimes solutions can be found outside of the box I just wanted to post the solution I found since it may help others. There is a free shell program named Flip - http://ccrma-www.stanford.edu/~craig/utility/flip/I added it as a button to my file manager app so I just NEED to select the files in question, click that button and it converts and uploads the files. I wouldn't have found it without the suggestions here so I truly appreaciate that. This has ended a very long battle.


Discussion

No Comment Found