LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-06-2003, 03:01 AM   #1
inspleak
LQ Newbie
 
Registered: Jul 2003
Location: Michigan
Posts: 21

Rep: Reputation: 15
DOS -> UNIX file conversion issue


Hey guys...
I have good news and bad news... (for me anyway )
Good new:
After many bashes of the head against the nearest brick wall I finally figured out why my CGI scripts sometimes don't work on some machines...

It turns out that the reason is if I edit the perl script on a windows box and upload it, it now is DOS formatted... this seems to be a bad thing for apache anyway on linux machines...
So to fix it I have found that I can copy the text out of the newly edited DOS formatted file and paste it into a file that I made on a linux machine... then save the new file over the old one...
Cool.. this seems to work... however I was looking for a less crude way of doing it... after a little searching I found that there
is a command dos2unix... I thought this would be the answer.. however it didn't quite work for me... Soooooo... I need a better solution...

the PERL scripts that work show up in EMACS with the litte "u" on the left side of the message bar at the bottom of the window... After I use dos2Unix on a file I don't get a "u" or a "(DOS)"... and I still get the same error from apache "Premature end of script headers".... the above solution does fix this but its a crappy fix...

this overly long winded question can be brought down to a few...
"Any ideas?"

oh.. and after each conversion I did check to make sure that the file permissions were set properly... so that isn't the problem

thanks so much for your help!!

-Jake
 
Old 07-06-2003, 12:30 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Take a look at NoteTab lite:
http://www.notetab.com

It can save files in UNIX format.
 
Old 07-06-2003, 04:52 PM   #3
inspleak
LQ Newbie
 
Registered: Jul 2003
Location: Michigan
Posts: 21

Original Poster
Rep: Reputation: 15
thanks for the suggestion! I will definatly look into it, however
I was looking for a way to do it in linux... thanks!

-Jake
 
Old 07-08-2003, 03:15 PM   #4
mramgopal
LQ Newbie
 
Registered: Jun 2003
Distribution: Mandrake 9.1
Posts: 17

Rep: Reputation: 0
Look - I have no idea of specifics , but your problem revolves around <CR> <LF> and dos to nix conversion as per my own experience - I could very well be wrong. Anyway - what I used to do was a small script - put in ascii and bring back in binary (perhaps the other way around - forgot now ) at the windows command prompt for 2 or 3 times. It works fine and can be automated when your lan has any nix box . Also most ftp s/w have options for crlf conversion , yu can explore that.
Hope this helps you .
 
Old 07-08-2003, 10:59 PM   #5
jlangelier
Member
 
Registered: Jun 2003
Location: Denver, CO
Distribution: Debian
Posts: 95

Rep: Reputation: 15
To convert DOS text to Unix text, at the console:

perl -i.bak -pe "s[\x0d\x0a][\x0a]g" <filename>

Note that <filename> can include wild cards. Your original file will be backed up with a .bak extension.

Also note that it's ZERO D and ZERO A, not OH D and OH A.
 
Old 07-04-2004, 01:24 AM   #6
Ninaw
Member
 
Registered: Jun 2004
Location: QC, Philippines
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 15
here's what I use
(dos to unix)

sed -e s/'\r'// yourDosFile > newFile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SED - Converting UNIX to DOS file aurelio26 Linux - Newbie 7 04-09-2008 01:15 AM
Dos to unix newlines Rotwang Linux - General 3 08-22-2005 02:45 PM
newline problem between DOS and Unix format cjs_pro Programming 7 03-11-2005 12:08 PM
Perl file conversion results in a truncated file kshaffer Programming 0 01-31-2005 03:31 PM
Unix to DOS text Wynd Programming 5 04-18-2003 01:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration